示例#1
0
		///<summary></summary>
		public static void Update(OrthoChart orthoChart) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),orthoChart);
				return;
			}
			Crud.OrthoChartCrud.Update(orthoChart);
		}
示例#2
0
		///<summary></summary>
		public static long Insert(OrthoChart orthoChart) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				orthoChart.OrthoChartNum=Meth.GetLong(MethodBase.GetCurrentMethod(),orthoChart);
				return orthoChart.OrthoChartNum;
			}
			return Crud.OrthoChartCrud.Insert(orthoChart);
		}
示例#3
0
文件: OrthoCharts.cs 项目: mnisl/OD
		///<summary></summary>
		public static void Update(OrthoChart orthoChart,OrthoChart oldOrthoChart) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),orthoChart,oldOrthoChart);
				return;
			}
			string command="";
			if(orthoChart.PatNum != oldOrthoChart.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(orthoChart.PatNum)+"";
			}
			if(orthoChart.DateService != oldOrthoChart.DateService) {
				if(command!=""){ command+=",";}
				command+="DateService = "+POut.Date(orthoChart.DateService)+"";
			}
			if(orthoChart.FieldName != oldOrthoChart.FieldName) {
				if(command!=""){ command+=",";}
				command+="FieldName = '"+POut.String(orthoChart.FieldName)+"'";
			}
			if(orthoChart.FieldValue != oldOrthoChart.FieldValue) {
				if(command!=""){ command+=",";}
				command+="FieldValue = '"+POut.String(orthoChart.FieldValue)+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE orthochart SET "+command
				+" WHERE OrthoChartNum = "+POut.Long(oldOrthoChart.OrthoChartNum);
			Db.NonQ(command);
			//Crud.OrthoChartCrud.Update(orthoChartNew,orthoChartOld);
		}
示例#4
0
 public static int SortDateField(OrthoChart x, OrthoChart y)
 {
     if (x.DateService != y.DateService)
     {
         return(x.DateService.CompareTo(y.DateService));
     }
     return(x.FieldName.CompareTo(y.FieldName));
 }
示例#5
0
        ///<summary></summary>
        public static void Update(OrthoChart orthoChart, OrthoChart oldOrthoChart)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), orthoChart, oldOrthoChart);
                return;
            }
            string command = "";

            if (orthoChart.PatNum != oldOrthoChart.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(orthoChart.PatNum) + "";
            }
            if (orthoChart.DateService != oldOrthoChart.DateService)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateService = " + POut.Date(orthoChart.DateService) + "";
            }
            if (orthoChart.FieldName != oldOrthoChart.FieldName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldName = '" + POut.String(orthoChart.FieldName) + "'";
            }
            if (orthoChart.FieldValue != oldOrthoChart.FieldValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "FieldValue = '" + POut.String(orthoChart.FieldValue) + "'";
            }
            if (orthoChart.UserNum != oldOrthoChart.UserNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "UserNum = '" + POut.Long(orthoChart.UserNum) + "'";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE orthochart SET " + command
                      + " WHERE OrthoChartNum = " + POut.Long(oldOrthoChart.OrthoChartNum);
            Db.NonQ(command);
            //Crud.OrthoChartCrud.Update(orthoChartNew,orthoChartOld);
        }
示例#6
0
 ///<summary></summary>
 public static void Update(OrthoChart orthoChart)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), orthoChart);
         return;
     }
     Crud.OrthoChartCrud.Update(orthoChart);
 }
示例#7
0
 ///<summary></summary>
 public static long Insert(OrthoChart orthoChart)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         orthoChart.OrthoChartNum = Meth.GetLong(MethodBase.GetCurrentMethod(), orthoChart);
         return(orthoChart.OrthoChartNum);
     }
     return(Crud.OrthoChartCrud.Insert(orthoChart));
 }
示例#8
0
		public FormOrthoChartEdit() {
			InitializeComponent();
			Lan.F(this);
			OrthoCur = new OrthoChart();
		}
示例#9
0
 private void FormOrthoChart_FormClosing(object sender,FormClosingEventArgs e)
 {
     //Save data from grid to table
     for(int i=0;i<gridMain.Rows.Count;i++) {
         table.Rows[i]["Date"]=gridMain.Rows[i].Tag;//store date
         for(int j=0;j<listOrthDisplayFields.Count;j++) {
             table.Rows[i][j+1]=gridMain.Rows[i].Cells[j+1].Text;
         }
     }
     List<OrthoChart> tempOrthoChartsFromDB=OrthoCharts.GetAllForPatient(PatCur.PatNum);
     List<OrthoChart> tempOrthoChartsFromTable=new List<OrthoChart>();
     for(int r=0;r<table.Rows.Count;r++) {
         for(int c=1;c<table.Columns.Count;c++) {//skip col 0
             OrthoChart tempChart = new OrthoChart();
             tempChart.DateService=(DateTime)table.Rows[r]["Date"];
             tempChart.FieldName=listOrthDisplayFields[c-1].Description;
             tempChart.FieldValue=table.Rows[r][c].ToString();
             tempChart.PatNum=PatCur.PatNum;
             tempOrthoChartsFromTable.Add(tempChart);
         }
     }
     //Check table list vs DB list for inserts, updates, and deletes.
     for(int i=0;i<tempOrthoChartsFromTable.Count;i++) {
         //Either delete an existing record from the DB or ignore this non-entry.
         if(tempOrthoChartsFromTable[i].FieldValue=="") {
             for(int j=0;j<tempOrthoChartsFromDB.Count;j++) {
                 if(tempOrthoChartsFromDB[j].DateService==tempOrthoChartsFromTable[i].DateService
                     && tempOrthoChartsFromDB[j].FieldName==tempOrthoChartsFromTable[i].FieldName)
                 {
                     OrthoCharts.Delete(tempOrthoChartsFromDB[j].OrthoChartNum);
                     break;
                 }
             }
             continue;//i loop
         }
         //Update the Record if it already exists or Insert if it's new.
         for(int j=0;j<=tempOrthoChartsFromDB.Count;j++) {
             //Insert if you've made it through the whole list.
             if(j==tempOrthoChartsFromDB.Count) {
                 OrthoCharts.Insert(tempOrthoChartsFromTable[i]);
                 break;
             }
             //Update if type and date match
             if(tempOrthoChartsFromDB[j].DateService==tempOrthoChartsFromTable[i].DateService
                     && tempOrthoChartsFromDB[j].FieldName==tempOrthoChartsFromTable[i].FieldName)
             {
                 tempOrthoChartsFromTable[i].OrthoChartNum=tempOrthoChartsFromDB[j].OrthoChartNum;
                 OrthoCharts.Update(tempOrthoChartsFromTable[i]);
                 break;
             }
         }
     }
 }
示例#10
0
		private void FormOrthoChart_FormClosing(object sender,FormClosingEventArgs e) {
			if(!_hasChanged) {
				return;
			}
			else if(DialogResult!=DialogResult.OK 
				&& _hasChanged && !MsgBox.Show(this,MsgBoxButtons.YesNo,"Unsaved changes will be lost. Would you like to save changes instead?")) 
			{
				return;
			}
			//Save data from grid to table
			for(int i=0;i<gridMain.Rows.Count;i++) {
				table.Rows[i]["Date"]=gridMain.Rows[i].Tag;//store date
				for(int j=0;j<_listOrthDisplayFields.Count;j++) {
					table.Rows[i][j+1]=gridMain.Rows[i].Cells[j+1].Text;
				}
			}
			//Modified Sync pattern.  We cannot use the standard Sync pattern here because we have to perform logging when updating or deleting.
			#region Modified Sync Pattern
			List<OrthoChart> listDB=OrthoCharts.GetAllForPatient(_patCur.PatNum);
			List<OrthoChart> listNew=new List<OrthoChart>();
			for(int r=0;r<table.Rows.Count;r++) {
				for(int c=1;c<table.Columns.Count;c++) {//skip col 0
					OrthoChart tempChart = new OrthoChart();
					tempChart.DateService=(DateTime)table.Rows[r]["Date"];
					tempChart.FieldName=_listOrthDisplayFields[c-1].Description;
					tempChart.FieldValue=table.Rows[r][c].ToString();
					tempChart.PatNum=_patCur.PatNum;
					listNew.Add(tempChart);
				}
			}
			//Inserts, updates, or deletes database rows to match supplied list.
			//Adding items to lists changes the order of operation. All inserts are completed first, then updates, then deletes.
			List<OrthoChart> listIns    =new List<OrthoChart>();
			List<OrthoChart> listUpdNew =new List<OrthoChart>();
			List<OrthoChart> listUpdDB  =new List<OrthoChart>();
			List<OrthoChart> listDel    =new List<OrthoChart>();
			List<string> listColNames=new List<string>();
			//Remove fields from the DB list that are not currently set to display.
			for(int i=0;i<_listOrthDisplayFields.Count;i++){
				listColNames.Add(_listOrthDisplayFields[i].Description);
			}
			for(int i=listDB.Count-1;i>=0;i--){
				if(!listColNames.Contains(listDB[i].FieldName)){
					listDB.RemoveAt(i);
				}
			}
			listNew.Sort(OrthoCharts.SortDateField);
			listDB.Sort(OrthoCharts.SortDateField);
			int idxNew=0;
			int idxDB=0;
			OrthoChart fieldNew;
			OrthoChart fieldDB;
			//Because both lists have been sorted using the same criteria, we can now walk each list to determine which list contians the next element.  The next element is determined by Primary Key.
			//If the New list contains the next item it will be inserted.  If the DB contains the next item, it will be deleted.  If both lists contain the next item, the item will be updated.
			while(idxNew<listNew.Count || idxDB<listDB.Count) {
				fieldNew=null;
				if(idxNew<listNew.Count) {
					fieldNew=listNew[idxNew];
				}
				fieldDB=null;
				if(idxDB<listDB.Count) {
					fieldDB=listDB[idxDB];
				}
				//begin compare
				if(fieldNew!=null && fieldDB==null) {//listNew has more items, listDB does not.
					listIns.Add(fieldNew);
					idxNew++;
					continue;
				}
				else if(fieldNew==null && fieldDB!=null) {//listDB has more items, listNew does not.
					listDel.Add(fieldDB);
					idxDB++;
					continue;
				}
				else if(fieldNew.DateService<fieldDB.DateService) {//newPK less than dbPK, newItem is 'next'
					listIns.Add(fieldNew);
					idxNew++;
					continue;
				}
				else if(fieldNew.DateService>fieldDB.DateService) {//dbPK less than newPK, dbItem is 'next'
					listDel.Add(fieldDB);
					idxDB++;
					continue;
				}
				else if(fieldNew.FieldName.CompareTo(fieldDB.FieldName)<0) {//New Fieldname Comes First
					listIns.Add(fieldNew);
					idxNew++;
					continue;
				}
				else if(fieldNew.FieldName.CompareTo(fieldDB.FieldName)>0) {//DB Fieldname Comes First
					listDel.Add(fieldDB);
					idxDB++;
					continue;
				}
				//Both lists contain the 'next' item, update required
				listUpdNew.Add(fieldNew);
				listUpdDB.Add(fieldDB);
				idxNew++;
				idxDB++;
			}
			//Commit changes to DB
			for(int i=0;i<listIns.Count;i++) {
				if(listIns[i].FieldValue=="") {//do not insert new blank values. This happens when fields from today are not used.
					continue;
				}
				OrthoCharts.Insert(listIns[i]);
			}
			for(int i=0;i<listUpdNew.Count;i++) {
				if(listUpdDB[i].FieldValue==listUpdNew[i].FieldValue) {
					continue;//values equal. do not update/create log entry.
				}
				if(listUpdNew[i].FieldValue!="") {//Actually update rows that have a new value.
					OrthoCharts.Update(listUpdNew[i],listUpdDB[i]);
				}
				else {//instead of updating to a blank value, we delete the row from the DB.
					listDel.Add(listUpdDB[i]);
				}
				#region security log entry
				SecurityLogs.MakeLogEntry(Permissions.OrthoChartEdit,_patCur.PatNum
					//DateService is parsed from this field in the audit trail function
					,Lan.g(this,"Ortho chart field edited.  Field date")+": "+listUpdNew[i].DateService.ToShortDateString()+"  "
					+Lan.g(this,"Field name")+": "+listUpdNew[i].FieldName+"\r\n"
					+Lan.g(this,"Old value")+": \""+listUpdDB[i].FieldValue+"\"  "
					+Lan.g(this,"New value")+": \""+listUpdNew[i].FieldValue+"\" "
					+listUpdDB[i].DateService.ToString("yyyyMMdd"));//This date stamp must be the last 8 characters for new OrthoEdit audit trail entries.
				#endregion
			}
			for(int i=0;i<listDel.Count;i++) {//All logging should have been performed above in the "Update block"
				OrthoCharts.Delete(listDel[i].OrthoChartNum);
			}
			#endregion
		}
示例#11
0
文件: OrthoCharts.cs 项目: mnisl/OD
		public static int SortDateField(OrthoChart x,OrthoChart y) {
			if(x.DateService!=y.DateService) {
				return x.DateService.CompareTo(y.DateService);
			}
			return x.FieldName.CompareTo(y.FieldName);
		}