/********************************************************************************************* * Copyright 2004 - Volian Enterprises, Inc. All rights reserved. * Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE * ------------------------------------------------------------------------------ * $Workfile: ProcExt.cs $ $Revision: 3 $ * $Author: Kathy $ $Date: 4/21/05 10:22a $ * * $History: ProcExt.cs $ * * ***************** Version 3 ***************** * User: Kathy Date: 4/21/05 Time: 10:22a * Updated in $/LibSource/VEObject * remove upgrade2005 define * * ***************** Version 2 ***************** * User: Kathy Date: 3/08/05 Time: 1:51p * Updated in $/LibSource/VEObject * Approval * * ***************** Version 1 ***************** * User: Kathy Date: 7/27/04 Time: 8:53a * Created in $/LibSource/VEObject *********************************************************************************************/ using System; using System.Collections; using System.Text; using System.IO; using System.Windows.Forms; using System.Data; using System.ComponentModel; using System.Diagnostics; using Utils; using VDB; namespace VEObject { /// /// VEO_ProcExt support procedure set functionality. /// public class VEO_ProcExt : VEO_Base { public string latestRev; // 30 char long public string latestPC; // 10 char long public string recID; // 8 char long public string approvalTD; private string tmpComment; private bool changeComment; private string _Comment; public DataRow drow; public VEO_ProcExt(string comment, string rev, string pc, string recid, string std, DataRow row) { changeComment=false; _Comment = comment; latestRev = rev; latestPC = pc; recID = recid; approvalTD = std; drow = row; if (std==null || std=="") approvalTD = "Not Approved"; else { DateTime dtx = System.Convert.ToDateTime(std); ThisTimeZone TZ = new ThisTimeZone(); TimeSpan TimeZoneSpan = TZ.GetUtcOffset(dtx); // Time Zone offset from UTC long TimeZoneAdj = Math.Abs(TimeZoneSpan.Ticks / 10000000); // convert to seconds DateTime cnv = dtx.AddSeconds(-TimeZoneAdj); approvalTD = cnv.ToLongDateString() + " " + cnv.ToLongTimeString(); } } [Description("Approved"),Category("Procedure Extension"),ReadOnly(true)]public string Approved { get{return approvalTD;} } [Description("Revision"),Category("Procedure Extension"),ReadOnly(true)]public string Revision { get{return latestRev;} } [Description("Change ID"),Category("Procedure Extension"),ReadOnly(true)]public string ChangeID { get{return latestPC;} } [Description("Comment"),Category("Procedure Extension")]public string Comment { get { if (!changeComment) return _Comment; else return tmpComment; } set { changeComment=true; tmpComment=value; } } public override void Restore() { changeComment=false; } public bool SaveNew(VEO_Proc prc, string srecid) { try { VEO_DummySet ds = (VEO_DummySet) prc.parentObj; // Add the record to the setext file. DataTable pdatatable = ds.vdbSetExt.DB_Data.Tables[0]; DataRow recidrow = pdatatable.Rows[0]; recidrow["RECID"]=srecid; DataRow pdatarow = pdatatable.NewRow(); recID = srecid; pdatarow["RECID"] = srecid; pdatarow["COMMENT"] = Comment; pdatarow["REV"] = System.DBNull.Value; pdatarow["PC"] = System.DBNull.Value; pdatatable.Rows.Add(pdatarow); ds.vdbSetExt.DB_Data = pdatarow.Table.DataSet; _Comment=Comment; changeComment=false; drow=pdatarow; prc.procExt = this; } catch (Exception e) { MessageBox.Show(e.Message,"Could not perform database functions required to add procedure."); return false; } return true; } public override bool Read(bool dummy) { return true; } public bool Write(VEO_DummySet dset) { bool dchange=false; VEO_ProcSet pset = (VEO_ProcSet) dset.parentObj; if (changeComment) { if((drow["COMMENT"]==System.DBNull.Value && tmpComment!=null) ||((string)drow["COMMENT"]!=tmpComment)) { drow["COMMENT"] = tmpComment; _Comment = tmpComment; changeComment=false; dchange=true; } } if(dchange) { try { dset.vdbSetExt.DB_Data = drow.Table.DataSet; } catch (Exception e) { MessageBox.Show(e.Message); return false; } } return true; } public void SetProcApprovedDate(string dbname, string ApprovedPath) { MessageBox.Show("Set Extention setting of approval date is not implemented yet"); /* * string apprfilepath = ApprovedPath + "\\" + dbname + ".dbf"; DateTime dt = File.GetLastWriteTime(apprfilepath); //C - CODE.... //get the approved file date/time stamp if ( getftime(apprfile, &ft) == -1) { Zfree(&buff); close(apprfile); return; } close(apprfile); // assign the file date/time to the Date and Time structures dt.da_year = ft.ft_year + 1980; dt.da_mon = (char)ft.ft_month; dt.da_day = (char)ft.ft_day; tm.ti_hour = (char)ft.ft_hour; tm.ti_min = (char)ft.ft_min; tm.ti_sec = (char)ft.ft_tsec << 1; // getdate(&dt); // gettime(&tm); (void) VDB_GetSetExtRecord(SetExtfd,rec,(char *)buff); buff->approvalTD=dostounix(&dt,&tm); NWSetMode(NWExclusive); if (!VDB_LockSetFile(SetExtfd)) return; (void) VDB_UpdateSetExtRecord(SetExtfd,rec,(char *)buff); NWResetMode(); VDB_UnLockSetFile(SetExtfd); Zfree(&buff); return; */ } } }