///<summary>Converts a list of Referral into a DataTable.</summary> public static DataTable ListToTable(List <Referral> listReferrals, string tableName = "") { if (string.IsNullOrEmpty(tableName)) { tableName = "Referral"; } DataTable table = new DataTable(tableName); table.Columns.Add("ReferralNum"); table.Columns.Add("LName"); table.Columns.Add("FName"); table.Columns.Add("MName"); table.Columns.Add("SSN"); table.Columns.Add("UsingTIN"); table.Columns.Add("Specialty"); table.Columns.Add("ST"); table.Columns.Add("Telephone"); table.Columns.Add("Address"); table.Columns.Add("Address2"); table.Columns.Add("City"); table.Columns.Add("Zip"); table.Columns.Add("Note"); table.Columns.Add("Phone2"); table.Columns.Add("IsHidden"); table.Columns.Add("NotPerson"); table.Columns.Add("Title"); table.Columns.Add("EMail"); table.Columns.Add("PatNum"); table.Columns.Add("NationalProvID"); table.Columns.Add("Slip"); table.Columns.Add("IsDoctor"); table.Columns.Add("IsTrustedDirect"); table.Columns.Add("DateTStamp"); table.Columns.Add("IsPreferred"); foreach (Referral referral in listReferrals) { table.Rows.Add(new object[] { POut.Long(referral.ReferralNum), referral.LName, referral.FName, referral.MName, referral.SSN, POut.Bool(referral.UsingTIN), POut.Long(referral.Specialty), referral.ST, referral.Telephone, referral.Address, referral.Address2, referral.City, referral.Zip, referral.Note, referral.Phone2, POut.Bool(referral.IsHidden), POut.Bool(referral.NotPerson), referral.Title, referral.EMail, POut.Long(referral.PatNum), referral.NationalProvID, POut.Long(referral.Slip), POut.Bool(referral.IsDoctor), POut.Bool(referral.IsTrustedDirect), POut.DateT(referral.DateTStamp, false), POut.Bool(referral.IsPreferred), }); } return(table); }
///<summary>Updates one Task in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables.</summary> public static void Update(Task task, Task oldTask) { string command = ""; if (task.TaskListNum != oldTask.TaskListNum) { if (command != "") { command += ","; } command += "TaskListNum = " + POut.Long(task.TaskListNum) + ""; } if (task.DateTask != oldTask.DateTask) { if (command != "") { command += ","; } command += "DateTask = " + POut.Date(task.DateTask) + ""; } if (task.KeyNum != oldTask.KeyNum) { if (command != "") { command += ","; } command += "KeyNum = " + POut.Long(task.KeyNum) + ""; } if (task.Descript != oldTask.Descript) { if (command != "") { command += ","; } command += "Descript = " + DbHelper.ParamChar + "paramDescript"; } if (task.TaskStatus != oldTask.TaskStatus) { if (command != "") { command += ","; } command += "TaskStatus = " + POut.Int((int)task.TaskStatus) + ""; } if (task.IsRepeating != oldTask.IsRepeating) { if (command != "") { command += ","; } command += "IsRepeating = " + POut.Bool(task.IsRepeating) + ""; } if (task.DateType != oldTask.DateType) { if (command != "") { command += ","; } command += "DateType = " + POut.Int((int)task.DateType) + ""; } if (task.FromNum != oldTask.FromNum) { if (command != "") { command += ","; } command += "FromNum = " + POut.Long(task.FromNum) + ""; } if (task.ObjectType != oldTask.ObjectType) { if (command != "") { command += ","; } command += "ObjectType = " + POut.Int((int)task.ObjectType) + ""; } if (task.DateTimeEntry != oldTask.DateTimeEntry) { if (command != "") { command += ","; } command += "DateTimeEntry = " + POut.DateT(task.DateTimeEntry) + ""; } if (task.UserNum != oldTask.UserNum) { if (command != "") { command += ","; } command += "UserNum = " + POut.Long(task.UserNum) + ""; } if (task.DateTimeFinished != oldTask.DateTimeFinished) { if (command != "") { command += ","; } command += "DateTimeFinished = " + POut.DateT(task.DateTimeFinished) + ""; } if (command == "") { return; } if (task.Descript == null) { task.Descript = ""; } OdSqlParameter paramDescript = new OdSqlParameter("paramDescript", OdDbType.Text, task.Descript); command = "UPDATE task SET " + command + " WHERE TaskNum = " + POut.Long(task.TaskNum); Db.NonQ(command, paramDescript); }
///<summary>Converts a list of Document into a DataTable.</summary> public static DataTable ListToTable(List <Document> listDocuments, string tableName = "") { if (string.IsNullOrEmpty(tableName)) { tableName = "Document"; } DataTable table = new DataTable(tableName); table.Columns.Add("DocNum"); table.Columns.Add("Description"); table.Columns.Add("DateCreated"); table.Columns.Add("DocCategory"); table.Columns.Add("PatNum"); table.Columns.Add("FileName"); table.Columns.Add("ImgType"); table.Columns.Add("IsFlipped"); table.Columns.Add("DegreesRotated"); table.Columns.Add("ToothNumbers"); table.Columns.Add("Note"); table.Columns.Add("SigIsTopaz"); table.Columns.Add("Signature"); table.Columns.Add("CropX"); table.Columns.Add("CropY"); table.Columns.Add("CropW"); table.Columns.Add("CropH"); table.Columns.Add("WindowingMin"); table.Columns.Add("WindowingMax"); table.Columns.Add("MountItemNum"); table.Columns.Add("DateTStamp"); table.Columns.Add("RawBase64"); table.Columns.Add("Thumbnail"); table.Columns.Add("ExternalGUID"); table.Columns.Add("ExternalSource"); foreach (Document document in listDocuments) { table.Rows.Add(new object[] { POut.Long(document.DocNum), document.Description, POut.DateT(document.DateCreated, false), POut.Long(document.DocCategory), POut.Long(document.PatNum), document.FileName, POut.Int((int)document.ImgType), POut.Bool(document.IsFlipped), POut.Int(document.DegreesRotated), document.ToothNumbers, document.Note, POut.Bool(document.SigIsTopaz), document.Signature, POut.Int(document.CropX), POut.Int(document.CropY), POut.Int(document.CropW), POut.Int(document.CropH), POut.Int(document.WindowingMin), POut.Int(document.WindowingMax), POut.Long(document.MountItemNum), POut.DateT(document.DateTStamp, false), document.RawBase64, document.Thumbnail, document.ExternalGUID, POut.Int((int)document.ExternalSource), }); } return(table); }
///<summary>Updates one Job in the database.</summary> public static void Update(Job job) { string command = "UPDATE job SET " + "UserNumConcept = " + POut.Long(job.UserNumConcept) + ", " + "UserNumExpert = " + POut.Long(job.UserNumExpert) + ", " + "UserNumEngineer = " + POut.Long(job.UserNumEngineer) + ", " + "UserNumApproverConcept = " + POut.Long(job.UserNumApproverConcept) + ", " + "UserNumApproverJob = " + POut.Long(job.UserNumApproverJob) + ", " + "UserNumApproverChange = " + POut.Long(job.UserNumApproverChange) + ", " + "UserNumDocumenter = " + POut.Long(job.UserNumDocumenter) + ", " + "UserNumCustContact = " + POut.Long(job.UserNumCustContact) + ", " + "UserNumCheckout = " + POut.Long(job.UserNumCheckout) + ", " + "UserNumInfo = " + POut.Long(job.UserNumInfo) + ", " + "ParentNum = " + POut.Long(job.ParentNum) + ", " + "DateTimeCustContact = " + POut.DateT(job.DateTimeCustContact) + ", " + "Priority = " + POut.Long(job.Priority) + ", " + "Category = '" + POut.String(job.Category.ToString()) + "', " + "JobVersion = '" + POut.String(job.JobVersion) + "', " + "TimeEstimateDevelopment= " + POut.Long(job.TimeEstimateDevelopment.Ticks) + ", " + "TimeActual = " + POut.Long(job.TimeActual.Ticks) + ", " //DateTimeEntry not allowed to change + "Implementation = " + DbHelper.ParamChar + "paramImplementation, " + "Documentation = " + DbHelper.ParamChar + "paramDocumentation, " + "Title = '" + POut.String(job.Title) + "', " + "PhaseCur = '" + POut.String(job.PhaseCur.ToString()) + "', " + "IsApprovalNeeded = " + POut.Bool(job.IsApprovalNeeded) + ", " + "AckDateTime = " + POut.DateT(job.AckDateTime) + ", " + "UserNumQuoter = " + POut.Long(job.UserNumQuoter) + ", " + "UserNumApproverQuote = " + POut.Long(job.UserNumApproverQuote) + ", " + "UserNumCustQuote = " + POut.Long(job.UserNumCustQuote) + ", " + "Requirements = " + DbHelper.ParamChar + "paramRequirements, " + "UserNumTester = " + POut.Long(job.UserNumTester) + ", " + "PriorityTesting = " + POut.Long(job.PriorityTesting) + ", " + "DateTimeTested = " + POut.DateT(job.DateTimeTested) + ", " + "TimeEstimateConcept = " + POut.Long(job.TimeEstimateConcept.Ticks) + ", " + "TimeEstimateWriteup = " + POut.Long(job.TimeEstimateWriteup.Ticks) + ", " + "TimeEstimateReview = " + POut.Long(job.TimeEstimateReview.Ticks) + ", " + "RequirementsJSON = " + DbHelper.ParamChar + "paramRequirementsJSON, " + "PatternReviewProject = " + POut.Int((int)job.PatternReviewProject) + ", " + "PatternReviewStatus = " + POut.Int((int)job.PatternReviewStatus) + ", " + "ProposedVersion = " + POut.Int((int)job.ProposedVersion) + ", " + "DateTimeConceptApproval= " + POut.DateT(job.DateTimeConceptApproval) + ", " + "DateTimeJobApproval = " + POut.DateT(job.DateTimeJobApproval) + ", " + "DateTimeImplemented = " + POut.DateT(job.DateTimeImplemented) + ", " + "TimeTesting = " + POut.Long(job.TimeTesting.Ticks) + ", " + "IsNotTested = " + POut.Bool(job.IsNotTested) + " " + "WHERE JobNum = " + POut.Long(job.JobNum); if (job.Implementation == null) { job.Implementation = ""; } OdSqlParameter paramImplementation = new OdSqlParameter("paramImplementation", OdDbType.Text, POut.StringParam(job.Implementation)); if (job.Documentation == null) { job.Documentation = ""; } OdSqlParameter paramDocumentation = new OdSqlParameter("paramDocumentation", OdDbType.Text, POut.StringParam(job.Documentation)); if (job.Requirements == null) { job.Requirements = ""; } OdSqlParameter paramRequirements = new OdSqlParameter("paramRequirements", OdDbType.Text, POut.StringParam(job.Requirements)); if (job.RequirementsJSON == null) { job.RequirementsJSON = ""; } OdSqlParameter paramRequirementsJSON = new OdSqlParameter("paramRequirementsJSON", OdDbType.Text, POut.StringParam(job.RequirementsJSON)); Db.NonQ(command, paramImplementation, paramDocumentation, paramRequirements, paramRequirementsJSON); }
///<summary>Inserts many SmsToMobiles into the database. Provides option to use the existing priKey.</summary> public static void InsertMany(List <SmsToMobile> listSmsToMobiles, bool useExistingPK) { if (!useExistingPK && PrefC.RandomKeys) { foreach (SmsToMobile smsToMobile in listSmsToMobiles) { Insert(smsToMobile); } } else { StringBuilder sbCommands = null; int index = 0; int countRows = 0; while (index < listSmsToMobiles.Count) { SmsToMobile smsToMobile = listSmsToMobiles[index]; StringBuilder sbRow = new StringBuilder("("); bool hasComma = false; if (sbCommands == null) { sbCommands = new StringBuilder(); sbCommands.Append("INSERT INTO smstomobile ("); if (useExistingPK) { sbCommands.Append("SmsToMobileNum,"); } sbCommands.Append("PatNum,GuidMessage,GuidBatch,SmsPhoneNumber,MobilePhoneNumber,IsTimeSensitive,MsgType,MsgText,SmsStatus,MsgParts,MsgChargeUSD,ClinicNum,CustErrorText,DateTimeSent,DateTimeTerminated,IsHidden,MsgDiscountUSD) VALUES "); countRows = 0; } else { hasComma = true; } if (useExistingPK) { sbRow.Append(POut.Long(smsToMobile.SmsToMobileNum)); sbRow.Append(","); } sbRow.Append(POut.Long(smsToMobile.PatNum)); sbRow.Append(","); sbRow.Append("'" + POut.String(smsToMobile.GuidMessage) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(smsToMobile.GuidBatch) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(smsToMobile.SmsPhoneNumber) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(smsToMobile.MobilePhoneNumber) + "'"); sbRow.Append(","); sbRow.Append(POut.Bool(smsToMobile.IsTimeSensitive)); sbRow.Append(","); sbRow.Append(POut.Int((int)smsToMobile.MsgType)); sbRow.Append(","); sbRow.Append("'" + POut.String(smsToMobile.MsgText) + "'"); sbRow.Append(","); sbRow.Append(POut.Int((int)smsToMobile.SmsStatus)); sbRow.Append(","); sbRow.Append(POut.Int(smsToMobile.MsgParts)); sbRow.Append(","); sbRow.Append(POut.Float(smsToMobile.MsgChargeUSD)); sbRow.Append(","); sbRow.Append(POut.Long(smsToMobile.ClinicNum)); sbRow.Append(","); sbRow.Append("'" + POut.String(smsToMobile.CustErrorText) + "'"); sbRow.Append(","); sbRow.Append(POut.DateT(smsToMobile.DateTimeSent)); sbRow.Append(","); sbRow.Append(POut.DateT(smsToMobile.DateTimeTerminated)); sbRow.Append(","); sbRow.Append(POut.Bool(smsToMobile.IsHidden)); sbRow.Append(","); sbRow.Append(POut.Float(smsToMobile.MsgDiscountUSD)); sbRow.Append(")"); //SecDateTEdit can only be set by MySQL if (sbCommands.Length + sbRow.Length + 1 > TableBase.MaxAllowedPacketCount && countRows > 0) { Db.NonQ(sbCommands.ToString()); sbCommands = null; } else { if (hasComma) { sbCommands.Append(","); } sbCommands.Append(sbRow.ToString()); countRows++; if (index == listSmsToMobiles.Count - 1) { Db.NonQ(sbCommands.ToString()); } index++; } } } }
///<summary>Updates one ApptReminderSent in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(ApptReminderSent apptReminderSent, ApptReminderSent oldApptReminderSent) { string command = ""; if (apptReminderSent.ApptNum != oldApptReminderSent.ApptNum) { if (command != "") { command += ","; } command += "ApptNum = " + POut.Long(apptReminderSent.ApptNum) + ""; } if (apptReminderSent.ApptDateTime != oldApptReminderSent.ApptDateTime) { if (command != "") { command += ","; } command += "ApptDateTime = " + POut.DateT(apptReminderSent.ApptDateTime) + ""; } if (apptReminderSent.DateTimeSent != oldApptReminderSent.DateTimeSent) { if (command != "") { command += ","; } command += "DateTimeSent = " + POut.DateT(apptReminderSent.DateTimeSent) + ""; } if (apptReminderSent.TSPrior != oldApptReminderSent.TSPrior) { if (command != "") { command += ","; } command += "TSPrior = '" + POut.Long(apptReminderSent.TSPrior.Ticks) + "'"; } if (apptReminderSent.ApptReminderRuleNum != oldApptReminderSent.ApptReminderRuleNum) { if (command != "") { command += ","; } command += "ApptReminderRuleNum = " + POut.Long(apptReminderSent.ApptReminderRuleNum) + ""; } if (apptReminderSent.IsSmsSent != oldApptReminderSent.IsSmsSent) { if (command != "") { command += ","; } command += "IsSmsSent = " + POut.Bool(apptReminderSent.IsSmsSent) + ""; } if (apptReminderSent.IsEmailSent != oldApptReminderSent.IsEmailSent) { if (command != "") { command += ","; } command += "IsEmailSent = " + POut.Bool(apptReminderSent.IsEmailSent) + ""; } if (command == "") { return(false); } command = "UPDATE apptremindersent SET " + command + " WHERE ApptReminderSentNum = " + POut.Long(apptReminderSent.ApptReminderSentNum); Db.NonQ(command); return(true); }
///<summary>Converts a list of Job into a DataTable.</summary> public static DataTable ListToTable(List <Job> listJobs, string tableName = "") { if (string.IsNullOrEmpty(tableName)) { tableName = "Job"; } DataTable table = new DataTable(tableName); table.Columns.Add("JobNum"); table.Columns.Add("UserNumConcept"); table.Columns.Add("UserNumExpert"); table.Columns.Add("UserNumEngineer"); table.Columns.Add("UserNumApproverConcept"); table.Columns.Add("UserNumApproverJob"); table.Columns.Add("UserNumApproverChange"); table.Columns.Add("UserNumDocumenter"); table.Columns.Add("UserNumCustContact"); table.Columns.Add("UserNumCheckout"); table.Columns.Add("UserNumInfo"); table.Columns.Add("ParentNum"); table.Columns.Add("DateTimeCustContact"); table.Columns.Add("Priority"); table.Columns.Add("Category"); table.Columns.Add("JobVersion"); table.Columns.Add("TimeEstimateDevelopment"); table.Columns.Add("TimeActual"); table.Columns.Add("DateTimeEntry"); table.Columns.Add("Implementation"); table.Columns.Add("Documentation"); table.Columns.Add("Title"); table.Columns.Add("PhaseCur"); table.Columns.Add("IsApprovalNeeded"); table.Columns.Add("AckDateTime"); table.Columns.Add("UserNumQuoter"); table.Columns.Add("UserNumApproverQuote"); table.Columns.Add("UserNumCustQuote"); table.Columns.Add("Requirements"); table.Columns.Add("UserNumTester"); table.Columns.Add("PriorityTesting"); table.Columns.Add("DateTimeTested"); table.Columns.Add("TimeEstimateConcept"); table.Columns.Add("TimeEstimateWriteup"); table.Columns.Add("TimeEstimateReview"); table.Columns.Add("RequirementsJSON"); table.Columns.Add("PatternReviewProject"); table.Columns.Add("PatternReviewStatus"); table.Columns.Add("ProposedVersion"); table.Columns.Add("DateTimeConceptApproval"); table.Columns.Add("DateTimeJobApproval"); table.Columns.Add("DateTimeImplemented"); table.Columns.Add("TimeTesting"); table.Columns.Add("IsNotTested"); foreach (Job job in listJobs) { table.Rows.Add(new object[] { POut.Long(job.JobNum), POut.Long(job.UserNumConcept), POut.Long(job.UserNumExpert), POut.Long(job.UserNumEngineer), POut.Long(job.UserNumApproverConcept), POut.Long(job.UserNumApproverJob), POut.Long(job.UserNumApproverChange), POut.Long(job.UserNumDocumenter), POut.Long(job.UserNumCustContact), POut.Long(job.UserNumCheckout), POut.Long(job.UserNumInfo), POut.Long(job.ParentNum), POut.DateT(job.DateTimeCustContact, false), POut.Long(job.Priority), POut.Int((int)job.Category), job.JobVersion, POut.Long(job.TimeEstimateDevelopment.Ticks), POut.Long(job.TimeActual.Ticks), POut.DateT(job.DateTimeEntry, false), job.Implementation, job.Documentation, job.Title, POut.Int((int)job.PhaseCur), POut.Bool(job.IsApprovalNeeded), POut.DateT(job.AckDateTime, false), POut.Long(job.UserNumQuoter), POut.Long(job.UserNumApproverQuote), POut.Long(job.UserNumCustQuote), job.Requirements, POut.Long(job.UserNumTester), POut.Long(job.PriorityTesting), POut.DateT(job.DateTimeTested, false), POut.Long(job.TimeEstimateConcept.Ticks), POut.Long(job.TimeEstimateWriteup.Ticks), POut.Long(job.TimeEstimateReview.Ticks), job.RequirementsJSON, POut.Int((int)job.PatternReviewProject), POut.Int((int)job.PatternReviewStatus), POut.Int((int)job.ProposedVersion), POut.DateT(job.DateTimeConceptApproval, false), POut.DateT(job.DateTimeJobApproval, false), POut.DateT(job.DateTimeImplemented, false), POut.Long(job.TimeTesting.Ticks), POut.Bool(job.IsNotTested), }); } return(table); }
///<summary>Converts a list of TaskHist into a DataTable.</summary> public static DataTable ListToTable(List <TaskHist> listTaskHists, string tableName = "") { if (string.IsNullOrEmpty(tableName)) { tableName = "TaskHist"; } DataTable table = new DataTable(tableName); table.Columns.Add("TaskHistNum"); table.Columns.Add("UserNumHist"); table.Columns.Add("DateTStamp"); table.Columns.Add("IsNoteChange"); table.Columns.Add("TaskNum"); table.Columns.Add("TaskListNum"); table.Columns.Add("DateTask"); table.Columns.Add("KeyNum"); table.Columns.Add("Descript"); table.Columns.Add("TaskStatus"); table.Columns.Add("IsRepeating"); table.Columns.Add("DateType"); table.Columns.Add("FromNum"); table.Columns.Add("ObjectType"); table.Columns.Add("DateTimeEntry"); table.Columns.Add("UserNum"); table.Columns.Add("DateTimeFinished"); table.Columns.Add("PriorityDefNum"); table.Columns.Add("ReminderGroupId"); table.Columns.Add("ReminderType"); table.Columns.Add("ReminderFrequency"); table.Columns.Add("DateTimeOriginal"); table.Columns.Add("SecDateTEdit"); foreach (TaskHist taskHist in listTaskHists) { table.Rows.Add(new object[] { POut.Long(taskHist.TaskHistNum), POut.Long(taskHist.UserNumHist), POut.DateT(taskHist.DateTStamp, false), POut.Bool(taskHist.IsNoteChange), POut.Long(taskHist.TaskNum), POut.Long(taskHist.TaskListNum), POut.DateT(taskHist.DateTask, false), POut.Long(taskHist.KeyNum), taskHist.Descript, POut.Int((int)taskHist.TaskStatus), POut.Bool(taskHist.IsRepeating), POut.Int((int)taskHist.DateType), POut.Long(taskHist.FromNum), POut.Int((int)taskHist.ObjectType), POut.DateT(taskHist.DateTimeEntry, false), POut.Long(taskHist.UserNum), POut.DateT(taskHist.DateTimeFinished, false), POut.Long(taskHist.PriorityDefNum), taskHist.ReminderGroupId, POut.Int((int)taskHist.ReminderType), POut.Int(taskHist.ReminderFrequency), POut.DateT(taskHist.DateTimeOriginal, false), POut.DateT(taskHist.SecDateTEdit, false), }); } return(table); }
///<summary>Converts a list of ProcedureCode into a DataTable.</summary> public static DataTable ListToTable(List <ProcedureCode> listProcedureCodes, string tableName = "") { if (string.IsNullOrEmpty(tableName)) { tableName = "ProcedureCode"; } DataTable table = new DataTable(tableName); table.Columns.Add("CodeNum"); table.Columns.Add("ProcCode"); table.Columns.Add("Descript"); table.Columns.Add("AbbrDesc"); table.Columns.Add("ProcTime"); table.Columns.Add("ProcCat"); table.Columns.Add("TreatArea"); table.Columns.Add("NoBillIns"); table.Columns.Add("IsProsth"); table.Columns.Add("DefaultNote"); table.Columns.Add("IsHygiene"); table.Columns.Add("GTypeNum"); table.Columns.Add("AlternateCode1"); table.Columns.Add("MedicalCode"); table.Columns.Add("IsTaxed"); table.Columns.Add("PaintType"); table.Columns.Add("GraphicColor"); table.Columns.Add("LaymanTerm"); table.Columns.Add("IsCanadianLab"); table.Columns.Add("PreExisting"); table.Columns.Add("BaseUnits"); table.Columns.Add("SubstitutionCode"); table.Columns.Add("SubstOnlyIf"); table.Columns.Add("DateTStamp"); table.Columns.Add("IsMultiVisit"); table.Columns.Add("DrugNDC"); table.Columns.Add("RevenueCodeDefault"); table.Columns.Add("ProvNumDefault"); table.Columns.Add("CanadaTimeUnits"); table.Columns.Add("IsRadiology"); table.Columns.Add("DefaultClaimNote"); table.Columns.Add("DefaultTPNote"); table.Columns.Add("BypassGlobalLock"); foreach (ProcedureCode procedureCode in listProcedureCodes) { table.Rows.Add(new object[] { POut.Long(procedureCode.CodeNum), procedureCode.ProcCode, procedureCode.Descript, procedureCode.AbbrDesc, procedureCode.ProcTime, POut.Long(procedureCode.ProcCat), POut.Int((int)procedureCode.TreatArea), POut.Bool(procedureCode.NoBillIns), POut.Bool(procedureCode.IsProsth), procedureCode.DefaultNote, POut.Bool(procedureCode.IsHygiene), POut.Int(procedureCode.GTypeNum), procedureCode.AlternateCode1, procedureCode.MedicalCode, POut.Bool(procedureCode.IsTaxed), POut.Int((int)procedureCode.PaintType), POut.Int(procedureCode.GraphicColor.ToArgb()), procedureCode.LaymanTerm, POut.Bool(procedureCode.IsCanadianLab), POut.Bool(procedureCode.PreExisting), POut.Int(procedureCode.BaseUnits), procedureCode.SubstitutionCode, POut.Int((int)procedureCode.SubstOnlyIf), POut.DateT(procedureCode.DateTStamp, false), POut.Bool(procedureCode.IsMultiVisit), procedureCode.DrugNDC, procedureCode.RevenueCodeDefault, POut.Long(procedureCode.ProvNumDefault), POut.Double(procedureCode.CanadaTimeUnits), POut.Bool(procedureCode.IsRadiology), procedureCode.DefaultClaimNote, procedureCode.DefaultTPNote, POut.Int((int)procedureCode.BypassGlobalLock), }); } return(table); }
///<summary>Updates one EmailMessage in the database.</summary> public static void Update(EmailMessage emailMessage) { string command = "UPDATE emailmessage SET " + "PatNum = " + POut.Long(emailMessage.PatNum) + ", " + "ToAddress = " + DbHelper.ParamChar + "paramToAddress, " + "FromAddress = " + DbHelper.ParamChar + "paramFromAddress, " + "Subject = " + DbHelper.ParamChar + "paramSubject, " + "BodyText = " + DbHelper.ParamChar + "paramBodyText, " + "MsgDateTime = " + POut.DateT(emailMessage.MsgDateTime) + ", " + "SentOrReceived = " + POut.Int((int)emailMessage.SentOrReceived) + ", " + "RecipientAddress= '" + POut.String(emailMessage.RecipientAddress) + "', " + "RawEmailIn = " + DbHelper.ParamChar + "paramRawEmailIn, " + "ProvNumWebMail = " + POut.Long(emailMessage.ProvNumWebMail) + ", " + "PatNumSubj = " + POut.Long(emailMessage.PatNumSubj) + ", " + "CcAddress = " + DbHelper.ParamChar + "paramCcAddress, " + "BccAddress = " + DbHelper.ParamChar + "paramBccAddress, " + "HideIn = " + POut.Int((int)emailMessage.HideIn) + ", " + "AptNum = " + POut.Long(emailMessage.AptNum) + ", " + "UserNum = " + POut.Long(emailMessage.UserNum) + ", " + "HtmlType = " + POut.Int((int)emailMessage.HtmlType) + " " + "WHERE EmailMessageNum = " + POut.Long(emailMessage.EmailMessageNum); if (emailMessage.ToAddress == null) { emailMessage.ToAddress = ""; } OdSqlParameter paramToAddress = new OdSqlParameter("paramToAddress", OdDbType.Text, POut.StringParam(emailMessage.ToAddress)); if (emailMessage.FromAddress == null) { emailMessage.FromAddress = ""; } OdSqlParameter paramFromAddress = new OdSqlParameter("paramFromAddress", OdDbType.Text, POut.StringParam(emailMessage.FromAddress)); if (emailMessage.Subject == null) { emailMessage.Subject = ""; } OdSqlParameter paramSubject = new OdSqlParameter("paramSubject", OdDbType.Text, POut.StringParam(emailMessage.Subject)); if (emailMessage.BodyText == null) { emailMessage.BodyText = ""; } OdSqlParameter paramBodyText = new OdSqlParameter("paramBodyText", OdDbType.Text, POut.StringParam(emailMessage.BodyText)); if (emailMessage.RawEmailIn == null) { emailMessage.RawEmailIn = ""; } OdSqlParameter paramRawEmailIn = new OdSqlParameter("paramRawEmailIn", OdDbType.Text, POut.StringParam(emailMessage.RawEmailIn)); if (emailMessage.CcAddress == null) { emailMessage.CcAddress = ""; } OdSqlParameter paramCcAddress = new OdSqlParameter("paramCcAddress", OdDbType.Text, POut.StringParam(emailMessage.CcAddress)); if (emailMessage.BccAddress == null) { emailMessage.BccAddress = ""; } OdSqlParameter paramBccAddress = new OdSqlParameter("paramBccAddress", OdDbType.Text, POut.StringParam(emailMessage.BccAddress)); Db.NonQ(command, paramToAddress, paramFromAddress, paramSubject, paramBodyText, paramRawEmailIn, paramCcAddress, paramBccAddress); }
///<summary>Updates one EmailMessage in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(EmailMessage emailMessage, EmailMessage oldEmailMessage) { string command = ""; if (emailMessage.PatNum != oldEmailMessage.PatNum) { if (command != "") { command += ","; } command += "PatNum = " + POut.Long(emailMessage.PatNum) + ""; } if (emailMessage.ToAddress != oldEmailMessage.ToAddress) { if (command != "") { command += ","; } command += "ToAddress = " + DbHelper.ParamChar + "paramToAddress"; } if (emailMessage.FromAddress != oldEmailMessage.FromAddress) { if (command != "") { command += ","; } command += "FromAddress = " + DbHelper.ParamChar + "paramFromAddress"; } if (emailMessage.Subject != oldEmailMessage.Subject) { if (command != "") { command += ","; } command += "Subject = " + DbHelper.ParamChar + "paramSubject"; } if (emailMessage.BodyText != oldEmailMessage.BodyText) { if (command != "") { command += ","; } command += "BodyText = " + DbHelper.ParamChar + "paramBodyText"; } if (emailMessage.MsgDateTime != oldEmailMessage.MsgDateTime) { if (command != "") { command += ","; } command += "MsgDateTime = " + POut.DateT(emailMessage.MsgDateTime) + ""; } if (emailMessage.SentOrReceived != oldEmailMessage.SentOrReceived) { if (command != "") { command += ","; } command += "SentOrReceived = " + POut.Int((int)emailMessage.SentOrReceived) + ""; } if (emailMessage.RecipientAddress != oldEmailMessage.RecipientAddress) { if (command != "") { command += ","; } command += "RecipientAddress = '" + POut.String(emailMessage.RecipientAddress) + "'"; } if (emailMessage.RawEmailIn != oldEmailMessage.RawEmailIn) { if (command != "") { command += ","; } command += "RawEmailIn = " + DbHelper.ParamChar + "paramRawEmailIn"; } if (emailMessage.ProvNumWebMail != oldEmailMessage.ProvNumWebMail) { if (command != "") { command += ","; } command += "ProvNumWebMail = " + POut.Long(emailMessage.ProvNumWebMail) + ""; } if (emailMessage.PatNumSubj != oldEmailMessage.PatNumSubj) { if (command != "") { command += ","; } command += "PatNumSubj = " + POut.Long(emailMessage.PatNumSubj) + ""; } if (emailMessage.CcAddress != oldEmailMessage.CcAddress) { if (command != "") { command += ","; } command += "CcAddress = " + DbHelper.ParamChar + "paramCcAddress"; } if (emailMessage.BccAddress != oldEmailMessage.BccAddress) { if (command != "") { command += ","; } command += "BccAddress = " + DbHelper.ParamChar + "paramBccAddress"; } if (emailMessage.HideIn != oldEmailMessage.HideIn) { if (command != "") { command += ","; } command += "HideIn = " + POut.Int((int)emailMessage.HideIn) + ""; } if (emailMessage.AptNum != oldEmailMessage.AptNum) { if (command != "") { command += ","; } command += "AptNum = " + POut.Long(emailMessage.AptNum) + ""; } if (emailMessage.UserNum != oldEmailMessage.UserNum) { if (command != "") { command += ","; } command += "UserNum = " + POut.Long(emailMessage.UserNum) + ""; } if (emailMessage.HtmlType != oldEmailMessage.HtmlType) { if (command != "") { command += ","; } command += "HtmlType = " + POut.Int((int)emailMessage.HtmlType) + ""; } if (command == "") { return(false); } if (emailMessage.ToAddress == null) { emailMessage.ToAddress = ""; } OdSqlParameter paramToAddress = new OdSqlParameter("paramToAddress", OdDbType.Text, POut.StringParam(emailMessage.ToAddress)); if (emailMessage.FromAddress == null) { emailMessage.FromAddress = ""; } OdSqlParameter paramFromAddress = new OdSqlParameter("paramFromAddress", OdDbType.Text, POut.StringParam(emailMessage.FromAddress)); if (emailMessage.Subject == null) { emailMessage.Subject = ""; } OdSqlParameter paramSubject = new OdSqlParameter("paramSubject", OdDbType.Text, POut.StringParam(emailMessage.Subject)); if (emailMessage.BodyText == null) { emailMessage.BodyText = ""; } OdSqlParameter paramBodyText = new OdSqlParameter("paramBodyText", OdDbType.Text, POut.StringParam(emailMessage.BodyText)); if (emailMessage.RawEmailIn == null) { emailMessage.RawEmailIn = ""; } OdSqlParameter paramRawEmailIn = new OdSqlParameter("paramRawEmailIn", OdDbType.Text, POut.StringParam(emailMessage.RawEmailIn)); if (emailMessage.CcAddress == null) { emailMessage.CcAddress = ""; } OdSqlParameter paramCcAddress = new OdSqlParameter("paramCcAddress", OdDbType.Text, POut.StringParam(emailMessage.CcAddress)); if (emailMessage.BccAddress == null) { emailMessage.BccAddress = ""; } OdSqlParameter paramBccAddress = new OdSqlParameter("paramBccAddress", OdDbType.Text, POut.StringParam(emailMessage.BccAddress)); command = "UPDATE emailmessage SET " + command + " WHERE EmailMessageNum = " + POut.Long(emailMessage.EmailMessageNum); Db.NonQ(command, paramToAddress, paramFromAddress, paramSubject, paramBodyText, paramRawEmailIn, paramCcAddress, paramBccAddress); return(true); }
///<summary>Inserts one EmailMessage into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(EmailMessage emailMessage, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO emailmessage ("; if (!useExistingPK && isRandomKeys) { emailMessage.EmailMessageNum = ReplicationServers.GetKeyNoCache("emailmessage", "EmailMessageNum"); } if (isRandomKeys || useExistingPK) { command += "EmailMessageNum,"; } command += "PatNum,ToAddress,FromAddress,Subject,BodyText,MsgDateTime,SentOrReceived,RecipientAddress,RawEmailIn,ProvNumWebMail,PatNumSubj,CcAddress,BccAddress,HideIn,AptNum,UserNum,HtmlType) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(emailMessage.EmailMessageNum) + ","; } command += POut.Long(emailMessage.PatNum) + "," + DbHelper.ParamChar + "paramToAddress," + DbHelper.ParamChar + "paramFromAddress," + DbHelper.ParamChar + "paramSubject," + DbHelper.ParamChar + "paramBodyText," + POut.DateT(emailMessage.MsgDateTime) + "," + POut.Int((int)emailMessage.SentOrReceived) + "," + "'" + POut.String(emailMessage.RecipientAddress) + "'," + DbHelper.ParamChar + "paramRawEmailIn," + POut.Long(emailMessage.ProvNumWebMail) + "," + POut.Long(emailMessage.PatNumSubj) + "," + DbHelper.ParamChar + "paramCcAddress," + DbHelper.ParamChar + "paramBccAddress," + POut.Int((int)emailMessage.HideIn) + "," + POut.Long(emailMessage.AptNum) + "," + POut.Long(emailMessage.UserNum) + "," + POut.Int((int)emailMessage.HtmlType) + ")"; if (emailMessage.ToAddress == null) { emailMessage.ToAddress = ""; } OdSqlParameter paramToAddress = new OdSqlParameter("paramToAddress", OdDbType.Text, POut.StringParam(emailMessage.ToAddress)); if (emailMessage.FromAddress == null) { emailMessage.FromAddress = ""; } OdSqlParameter paramFromAddress = new OdSqlParameter("paramFromAddress", OdDbType.Text, POut.StringParam(emailMessage.FromAddress)); if (emailMessage.Subject == null) { emailMessage.Subject = ""; } OdSqlParameter paramSubject = new OdSqlParameter("paramSubject", OdDbType.Text, POut.StringParam(emailMessage.Subject)); if (emailMessage.BodyText == null) { emailMessage.BodyText = ""; } OdSqlParameter paramBodyText = new OdSqlParameter("paramBodyText", OdDbType.Text, POut.StringParam(emailMessage.BodyText)); if (emailMessage.RawEmailIn == null) { emailMessage.RawEmailIn = ""; } OdSqlParameter paramRawEmailIn = new OdSqlParameter("paramRawEmailIn", OdDbType.Text, POut.StringParam(emailMessage.RawEmailIn)); if (emailMessage.CcAddress == null) { emailMessage.CcAddress = ""; } OdSqlParameter paramCcAddress = new OdSqlParameter("paramCcAddress", OdDbType.Text, POut.StringParam(emailMessage.CcAddress)); if (emailMessage.BccAddress == null) { emailMessage.BccAddress = ""; } OdSqlParameter paramBccAddress = new OdSqlParameter("paramBccAddress", OdDbType.Text, POut.StringParam(emailMessage.BccAddress)); if (useExistingPK || isRandomKeys) { Db.NonQ(command, paramToAddress, paramFromAddress, paramSubject, paramBodyText, paramRawEmailIn, paramCcAddress, paramBccAddress); } else { emailMessage.EmailMessageNum = Db.NonQ(command, true, "EmailMessageNum", "emailMessage", paramToAddress, paramFromAddress, paramSubject, paramBodyText, paramRawEmailIn, paramCcAddress, paramBccAddress); } return(emailMessage.EmailMessageNum); }
///<summary>Converts a list of SmsBilling into a DataTable.</summary> public static DataTable ListToTable(List <SmsBilling> listSmsBillings, string tableName = "") { if (string.IsNullOrEmpty(tableName)) { tableName = "SmsBilling"; } DataTable table = new DataTable(tableName); table.Columns.Add("SmsBillingNum"); table.Columns.Add("RegistrationKeyNum"); table.Columns.Add("CustPatNum"); table.Columns.Add("DateUsage"); table.Columns.Add("MsgChargeTotalUSD"); table.Columns.Add("AccessChargeTotalUSD"); table.Columns.Add("ClinicsTotalCount"); table.Columns.Add("ClinicsActiveCount"); table.Columns.Add("ClinicsUsedCount"); table.Columns.Add("PhonesTotalCount"); table.Columns.Add("PhonesActiveCount"); table.Columns.Add("PhonesUsedCount"); table.Columns.Add("MsgSentOkCount"); table.Columns.Add("MsgRcvOkCount"); table.Columns.Add("MsgSentFailCount"); table.Columns.Add("MsgRcvFailCount"); table.Columns.Add("ConfirmationClinics"); table.Columns.Add("ConfirmationsTotal"); table.Columns.Add("ConfirmationsEmail"); table.Columns.Add("ConfirmationsSms"); table.Columns.Add("ConfirmationChargeTotalUSD"); table.Columns.Add("BillingDescSms"); table.Columns.Add("BillingDescConfirmation"); foreach (SmsBilling smsBilling in listSmsBillings) { table.Rows.Add(new object[] { POut.Long(smsBilling.SmsBillingNum), POut.Long(smsBilling.RegistrationKeyNum), POut.Long(smsBilling.CustPatNum), POut.DateT(smsBilling.DateUsage, false), POut.Float(smsBilling.MsgChargeTotalUSD), POut.Float(smsBilling.AccessChargeTotalUSD), POut.Int(smsBilling.ClinicsTotalCount), POut.Int(smsBilling.ClinicsActiveCount), POut.Int(smsBilling.ClinicsUsedCount), POut.Int(smsBilling.PhonesTotalCount), POut.Int(smsBilling.PhonesActiveCount), POut.Int(smsBilling.PhonesUsedCount), POut.Int(smsBilling.MsgSentOkCount), POut.Int(smsBilling.MsgRcvOkCount), POut.Int(smsBilling.MsgSentFailCount), POut.Int(smsBilling.MsgRcvFailCount), POut.Int(smsBilling.ConfirmationClinics), POut.Int(smsBilling.ConfirmationsTotal), POut.Int(smsBilling.ConfirmationsEmail), POut.Int(smsBilling.ConfirmationsSms), POut.Float(smsBilling.ConfirmationChargeTotalUSD), smsBilling.BillingDescSms, smsBilling.BillingDescConfirmation, }); } return(table); }
///<summary>Updates one TimeAdjust in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(TimeAdjust timeAdjust, TimeAdjust oldTimeAdjust) { string command = ""; if (timeAdjust.EmployeeNum != oldTimeAdjust.EmployeeNum) { if (command != "") { command += ","; } command += "EmployeeNum = " + POut.Long(timeAdjust.EmployeeNum) + ""; } if (timeAdjust.TimeEntry != oldTimeAdjust.TimeEntry) { if (command != "") { command += ","; } command += "TimeEntry = " + POut.DateT(timeAdjust.TimeEntry) + ""; } if (timeAdjust.RegHours != oldTimeAdjust.RegHours) { if (command != "") { command += ","; } command += "RegHours = '" + POut.TSpan(timeAdjust.RegHours) + "'"; } if (timeAdjust.OTimeHours != oldTimeAdjust.OTimeHours) { if (command != "") { command += ","; } command += "OTimeHours = '" + POut.TSpan(timeAdjust.OTimeHours) + "'"; } if (timeAdjust.Note != oldTimeAdjust.Note) { if (command != "") { command += ","; } command += "Note = " + DbHelper.ParamChar + "paramNote"; } if (timeAdjust.IsAuto != oldTimeAdjust.IsAuto) { if (command != "") { command += ","; } command += "IsAuto = " + POut.Bool(timeAdjust.IsAuto) + ""; } if (timeAdjust.ClinicNum != oldTimeAdjust.ClinicNum) { if (command != "") { command += ","; } command += "ClinicNum = " + POut.Long(timeAdjust.ClinicNum) + ""; } if (timeAdjust.PtoDefNum != oldTimeAdjust.PtoDefNum) { if (command != "") { command += ","; } command += "PtoDefNum = " + POut.Long(timeAdjust.PtoDefNum) + ""; } if (timeAdjust.PtoHours != oldTimeAdjust.PtoHours) { if (command != "") { command += ","; } command += "PtoHours = '" + POut.TSpan(timeAdjust.PtoHours) + "'"; } if (command == "") { return(false); } if (timeAdjust.Note == null) { timeAdjust.Note = ""; } OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(timeAdjust.Note)); command = "UPDATE timeadjust SET " + command + " WHERE TimeAdjustNum = " + POut.Long(timeAdjust.TimeAdjustNum); Db.NonQ(command, paramNote); return(true); }
///<summary>Updates one VaccinePat in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(VaccinePat vaccinePat, VaccinePat oldVaccinePat) { string command = ""; if (vaccinePat.VaccineDefNum != oldVaccinePat.VaccineDefNum) { if (command != "") { command += ","; } command += "VaccineDefNum = " + POut.Long(vaccinePat.VaccineDefNum) + ""; } if (vaccinePat.DateTimeStart != oldVaccinePat.DateTimeStart) { if (command != "") { command += ","; } command += "DateTimeStart = " + POut.DateT(vaccinePat.DateTimeStart) + ""; } if (vaccinePat.DateTimeEnd != oldVaccinePat.DateTimeEnd) { if (command != "") { command += ","; } command += "DateTimeEnd = " + POut.DateT(vaccinePat.DateTimeEnd) + ""; } if (vaccinePat.AdministeredAmt != oldVaccinePat.AdministeredAmt) { if (command != "") { command += ","; } command += "AdministeredAmt = " + POut.Float(vaccinePat.AdministeredAmt) + ""; } if (vaccinePat.DrugUnitNum != oldVaccinePat.DrugUnitNum) { if (command != "") { command += ","; } command += "DrugUnitNum = " + POut.Long(vaccinePat.DrugUnitNum) + ""; } if (vaccinePat.LotNumber != oldVaccinePat.LotNumber) { if (command != "") { command += ","; } command += "LotNumber = '" + POut.String(vaccinePat.LotNumber) + "'"; } if (vaccinePat.PatNum != oldVaccinePat.PatNum) { if (command != "") { command += ","; } command += "PatNum = " + POut.Long(vaccinePat.PatNum) + ""; } if (vaccinePat.Note != oldVaccinePat.Note) { if (command != "") { command += ","; } command += "Note = " + DbHelper.ParamChar + "paramNote"; } if (vaccinePat.FilledCity != oldVaccinePat.FilledCity) { if (command != "") { command += ","; } command += "FilledCity = '" + POut.String(vaccinePat.FilledCity) + "'"; } if (vaccinePat.FilledST != oldVaccinePat.FilledST) { if (command != "") { command += ","; } command += "FilledST = '" + POut.String(vaccinePat.FilledST) + "'"; } if (vaccinePat.CompletionStatus != oldVaccinePat.CompletionStatus) { if (command != "") { command += ","; } command += "CompletionStatus = " + POut.Int((int)vaccinePat.CompletionStatus) + ""; } if (vaccinePat.AdministrationNoteCode != oldVaccinePat.AdministrationNoteCode) { if (command != "") { command += ","; } command += "AdministrationNoteCode = " + POut.Int((int)vaccinePat.AdministrationNoteCode) + ""; } if (vaccinePat.UserNum != oldVaccinePat.UserNum) { if (command != "") { command += ","; } command += "UserNum = " + POut.Long(vaccinePat.UserNum) + ""; } if (vaccinePat.ProvNumOrdering != oldVaccinePat.ProvNumOrdering) { if (command != "") { command += ","; } command += "ProvNumOrdering = " + POut.Long(vaccinePat.ProvNumOrdering) + ""; } if (vaccinePat.ProvNumAdminister != oldVaccinePat.ProvNumAdminister) { if (command != "") { command += ","; } command += "ProvNumAdminister = " + POut.Long(vaccinePat.ProvNumAdminister) + ""; } if (vaccinePat.DateExpire.Date != oldVaccinePat.DateExpire.Date) { if (command != "") { command += ","; } command += "DateExpire = " + POut.Date(vaccinePat.DateExpire) + ""; } if (vaccinePat.RefusalReason != oldVaccinePat.RefusalReason) { if (command != "") { command += ","; } command += "RefusalReason = " + POut.Int((int)vaccinePat.RefusalReason) + ""; } if (vaccinePat.ActionCode != oldVaccinePat.ActionCode) { if (command != "") { command += ","; } command += "ActionCode = " + POut.Int((int)vaccinePat.ActionCode) + ""; } if (vaccinePat.AdministrationRoute != oldVaccinePat.AdministrationRoute) { if (command != "") { command += ","; } command += "AdministrationRoute = " + POut.Int((int)vaccinePat.AdministrationRoute) + ""; } if (vaccinePat.AdministrationSite != oldVaccinePat.AdministrationSite) { if (command != "") { command += ","; } command += "AdministrationSite = " + POut.Int((int)vaccinePat.AdministrationSite) + ""; } if (command == "") { return(false); } if (vaccinePat.Note == null) { vaccinePat.Note = ""; } OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(vaccinePat.Note)); command = "UPDATE vaccinepat SET " + command + " WHERE VaccinePatNum = " + POut.Long(vaccinePat.VaccinePatNum); Db.NonQ(command, paramNote); return(true); }
///<summary>Updates one Phone in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(Phone phone, Phone oldPhone) { string command = ""; if (phone.Extension != oldPhone.Extension) { if (command != "") { command += ","; } command += "Extension = " + POut.Int(phone.Extension) + ""; } if (phone.EmployeeName != oldPhone.EmployeeName) { if (command != "") { command += ","; } command += "EmployeeName = '" + POut.String(phone.EmployeeName) + "'"; } if (phone.ClockStatus != oldPhone.ClockStatus) { if (command != "") { command += ","; } command += "ClockStatus = '" + POut.String(phone.ClockStatus.ToString()) + "'"; } if (phone.Description != oldPhone.Description) { if (command != "") { command += ","; } command += "Description = '" + POut.String(phone.Description) + "'"; } if (phone.ColorBar != oldPhone.ColorBar) { if (command != "") { command += ","; } command += "ColorBar = " + POut.Int(phone.ColorBar.ToArgb()) + ""; } if (phone.ColorText != oldPhone.ColorText) { if (command != "") { command += ","; } command += "ColorText = " + POut.Int(phone.ColorText.ToArgb()) + ""; } if (phone.EmployeeNum != oldPhone.EmployeeNum) { if (command != "") { command += ","; } command += "EmployeeNum = " + POut.Long(phone.EmployeeNum) + ""; } if (phone.CustomerNumber != oldPhone.CustomerNumber) { if (command != "") { command += ","; } command += "CustomerNumber = '" + POut.String(phone.CustomerNumber) + "'"; } if (phone.InOrOut != oldPhone.InOrOut) { if (command != "") { command += ","; } command += "InOrOut = '" + POut.String(phone.InOrOut) + "'"; } if (phone.PatNum != oldPhone.PatNum) { if (command != "") { command += ","; } command += "PatNum = " + POut.Long(phone.PatNum) + ""; } if (phone.DateTimeStart != oldPhone.DateTimeStart) { if (command != "") { command += ","; } command += "DateTimeStart = " + POut.DateT(phone.DateTimeStart) + ""; } if (phone.CustomerNumberRaw != oldPhone.CustomerNumberRaw) { if (command != "") { command += ","; } command += "CustomerNumberRaw = '" + POut.String(phone.CustomerNumberRaw) + "'"; } if (phone.LastCallTimeStart != oldPhone.LastCallTimeStart) { if (command != "") { command += ","; } command += "LastCallTimeStart = " + POut.DateT(phone.LastCallTimeStart) + ""; } if (phone.RingGroups != oldPhone.RingGroups) { if (command != "") { command += ","; } command += "RingGroups = " + POut.Int((int)phone.RingGroups) + ""; } if (phone.IsProximal != oldPhone.IsProximal) { if (command != "") { command += ","; } command += "IsProximal = " + POut.Bool(phone.IsProximal) + ""; } if (phone.DateTimeNeedsHelpStart.Date != oldPhone.DateTimeNeedsHelpStart.Date) { if (command != "") { command += ","; } command += "DateTimeNeedsHelpStart = " + POut.Date(phone.DateTimeNeedsHelpStart) + ""; } if (phone.DateTProximal.Date != oldPhone.DateTProximal.Date) { if (command != "") { command += ","; } command += "DateTProximal = " + POut.Date(phone.DateTProximal) + ""; } if (command == "") { return(false); } command = "UPDATE phone SET " + command + " WHERE PhoneNum = " + POut.Long(phone.PhoneNum); Db.NonQ(command); return(true); }
///<summary>Inserts many ApptReminderSents into the database. Provides option to use the existing priKey.</summary> public static void InsertMany(List <ApptReminderSent> listApptReminderSents, bool useExistingPK) { if (!useExistingPK && PrefC.RandomKeys) { foreach (ApptReminderSent apptReminderSent in listApptReminderSents) { Insert(apptReminderSent); } } else { StringBuilder sbCommands = null; int index = 0; int countRows = 0; while (index < listApptReminderSents.Count) { ApptReminderSent apptReminderSent = listApptReminderSents[index]; StringBuilder sbRow = new StringBuilder("("); bool hasComma = false; if (sbCommands == null) { sbCommands = new StringBuilder(); sbCommands.Append("INSERT INTO apptremindersent ("); if (useExistingPK) { sbCommands.Append("ApptReminderSentNum,"); } sbCommands.Append("ApptNum,ApptDateTime,DateTimeSent,TSPrior,ApptReminderRuleNum,IsSmsSent,IsEmailSent) VALUES "); countRows = 0; } else { hasComma = true; } if (useExistingPK) { sbRow.Append(POut.Long(apptReminderSent.ApptReminderSentNum)); sbRow.Append(","); } sbRow.Append(POut.Long(apptReminderSent.ApptNum)); sbRow.Append(","); sbRow.Append(POut.DateT(apptReminderSent.ApptDateTime)); sbRow.Append(","); sbRow.Append(POut.DateT(apptReminderSent.DateTimeSent)); sbRow.Append(","); sbRow.Append("'" + POut.Long(apptReminderSent.TSPrior.Ticks) + "'"); sbRow.Append(","); sbRow.Append(POut.Long(apptReminderSent.ApptReminderRuleNum)); sbRow.Append(","); sbRow.Append(POut.Bool(apptReminderSent.IsSmsSent)); sbRow.Append(","); sbRow.Append(POut.Bool(apptReminderSent.IsEmailSent)); sbRow.Append(")"); if (sbCommands.Length + sbRow.Length + 1 > TableBase.MaxAllowedPacketCount && countRows > 0) { Db.NonQ(sbCommands.ToString()); sbCommands = null; } else { if (hasComma) { sbCommands.Append(","); } sbCommands.Append(sbRow.ToString()); countRows++; if (index == listApptReminderSents.Count - 1) { Db.NonQ(sbCommands.ToString()); } index++; } } } }
///<summary>Inserts many AsapComms into the database. Provides option to use the existing priKey.</summary> public static void InsertMany(List <AsapComm> listAsapComms, bool useExistingPK) { if (!useExistingPK && PrefC.RandomKeys) { foreach (AsapComm asapComm in listAsapComms) { Insert(asapComm); } } else { StringBuilder sbCommands = null; int index = 0; int countRows = 0; while (index < listAsapComms.Count) { AsapComm asapComm = listAsapComms[index]; StringBuilder sbRow = new StringBuilder("("); bool hasComma = false; if (sbCommands == null) { sbCommands = new StringBuilder(); sbCommands.Append("INSERT INTO asapcomm ("); if (useExistingPK) { sbCommands.Append("AsapCommNum,"); } sbCommands.Append("FKey,FKeyType,ScheduleNum,PatNum,ClinicNum,ShortGUID,DateTimeEntry,DateTimeExpire,DateTimeSmsScheduled,SmsSendStatus,EmailSendStatus,DateTimeSmsSent,DateTimeEmailSent,EmailMessageNum,ResponseStatus,DateTimeOrig,TemplateText,TemplateEmail,TemplateEmailSubj,Note,GuidMessageToMobile) VALUES "); countRows = 0; } else { hasComma = true; } if (useExistingPK) { sbRow.Append(POut.Long(asapComm.AsapCommNum)); sbRow.Append(","); } sbRow.Append(POut.Long(asapComm.FKey)); sbRow.Append(","); sbRow.Append(POut.Int((int)asapComm.FKeyType)); sbRow.Append(","); sbRow.Append(POut.Long(asapComm.ScheduleNum)); sbRow.Append(","); sbRow.Append(POut.Long(asapComm.PatNum)); sbRow.Append(","); sbRow.Append(POut.Long(asapComm.ClinicNum)); sbRow.Append(","); sbRow.Append("'" + POut.String(asapComm.ShortGUID) + "'"); sbRow.Append(","); sbRow.Append(DbHelper.Now()); sbRow.Append(","); sbRow.Append(POut.DateT(asapComm.DateTimeExpire)); sbRow.Append(","); sbRow.Append(POut.DateT(asapComm.DateTimeSmsScheduled)); sbRow.Append(","); sbRow.Append(POut.Int((int)asapComm.SmsSendStatus)); sbRow.Append(","); sbRow.Append(POut.Int((int)asapComm.EmailSendStatus)); sbRow.Append(","); sbRow.Append(POut.DateT(asapComm.DateTimeSmsSent)); sbRow.Append(","); sbRow.Append(POut.DateT(asapComm.DateTimeEmailSent)); sbRow.Append(","); sbRow.Append(POut.Long(asapComm.EmailMessageNum)); sbRow.Append(","); sbRow.Append(POut.Int((int)asapComm.ResponseStatus)); sbRow.Append(","); sbRow.Append(POut.DateT(asapComm.DateTimeOrig)); sbRow.Append(","); sbRow.Append("'" + POut.String(asapComm.TemplateText) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(asapComm.TemplateEmail) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(asapComm.TemplateEmailSubj) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(asapComm.Note) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(asapComm.GuidMessageToMobile) + "'"); sbRow.Append(")"); if (sbCommands.Length + sbRow.Length + 1 > TableBase.MaxAllowedPacketCount && countRows > 0) { Db.NonQ(sbCommands.ToString()); sbCommands = null; } else { if (hasComma) { sbCommands.Append(","); } sbCommands.Append(sbRow.ToString()); countRows++; if (index == listAsapComms.Count - 1) { Db.NonQ(sbCommands.ToString()); } index++; } } } }
///<summary>Updates one SmsPhone in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(SmsPhone smsPhone, SmsPhone oldSmsPhone) { string command = ""; if (smsPhone.ClinicNum != oldSmsPhone.ClinicNum) { if (command != "") { command += ","; } command += "ClinicNum = " + POut.Long(smsPhone.ClinicNum) + ""; } if (smsPhone.PhoneNumber != oldSmsPhone.PhoneNumber) { if (command != "") { command += ","; } command += "PhoneNumber = '" + POut.String(smsPhone.PhoneNumber) + "'"; } if (smsPhone.DateTimeActive != oldSmsPhone.DateTimeActive) { if (command != "") { command += ","; } command += "DateTimeActive = " + POut.DateT(smsPhone.DateTimeActive) + ""; } if (smsPhone.DateTimeInactive != oldSmsPhone.DateTimeInactive) { if (command != "") { command += ","; } command += "DateTimeInactive = " + POut.DateT(smsPhone.DateTimeInactive) + ""; } if (smsPhone.InactiveCode != oldSmsPhone.InactiveCode) { if (command != "") { command += ","; } command += "InactiveCode = '" + POut.String(smsPhone.InactiveCode) + "'"; } if (smsPhone.CountryCode != oldSmsPhone.CountryCode) { if (command != "") { command += ","; } command += "CountryCode = '" + POut.String(smsPhone.CountryCode) + "'"; } if (command == "") { return(false); } command = "UPDATE smsphone SET " + command + " WHERE SmsPhoneNum = " + POut.Long(smsPhone.SmsPhoneNum); Db.NonQ(command); return(true); }
///<summary>Inserts one AsapComm into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(AsapComm asapComm, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO asapcomm ("; if (!useExistingPK && isRandomKeys) { asapComm.AsapCommNum = ReplicationServers.GetKeyNoCache("asapcomm", "AsapCommNum"); } if (isRandomKeys || useExistingPK) { command += "AsapCommNum,"; } command += "FKey,FKeyType,ScheduleNum,PatNum,ClinicNum,ShortGUID,DateTimeEntry,DateTimeExpire,DateTimeSmsScheduled,SmsSendStatus,EmailSendStatus,DateTimeSmsSent,DateTimeEmailSent,EmailMessageNum,ResponseStatus,DateTimeOrig,TemplateText,TemplateEmail,TemplateEmailSubj,Note,GuidMessageToMobile) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(asapComm.AsapCommNum) + ","; } command += POut.Long(asapComm.FKey) + "," + POut.Int((int)asapComm.FKeyType) + "," + POut.Long(asapComm.ScheduleNum) + "," + POut.Long(asapComm.PatNum) + "," + POut.Long(asapComm.ClinicNum) + "," + "'" + POut.String(asapComm.ShortGUID) + "'," + DbHelper.Now() + "," + POut.DateT(asapComm.DateTimeExpire) + "," + POut.DateT(asapComm.DateTimeSmsScheduled) + "," + POut.Int((int)asapComm.SmsSendStatus) + "," + POut.Int((int)asapComm.EmailSendStatus) + "," + POut.DateT(asapComm.DateTimeSmsSent) + "," + POut.DateT(asapComm.DateTimeEmailSent) + "," + POut.Long(asapComm.EmailMessageNum) + "," + POut.Int((int)asapComm.ResponseStatus) + "," + POut.DateT(asapComm.DateTimeOrig) + "," + DbHelper.ParamChar + "paramTemplateText," + DbHelper.ParamChar + "paramTemplateEmail," + "'" + POut.String(asapComm.TemplateEmailSubj) + "'," + DbHelper.ParamChar + "paramNote," + DbHelper.ParamChar + "paramGuidMessageToMobile)"; if (asapComm.TemplateText == null) { asapComm.TemplateText = ""; } OdSqlParameter paramTemplateText = new OdSqlParameter("paramTemplateText", OdDbType.Text, POut.StringParam(asapComm.TemplateText)); if (asapComm.TemplateEmail == null) { asapComm.TemplateEmail = ""; } OdSqlParameter paramTemplateEmail = new OdSqlParameter("paramTemplateEmail", OdDbType.Text, POut.StringParam(asapComm.TemplateEmail)); if (asapComm.Note == null) { asapComm.Note = ""; } OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(asapComm.Note)); if (asapComm.GuidMessageToMobile == null) { asapComm.GuidMessageToMobile = ""; } OdSqlParameter paramGuidMessageToMobile = new OdSqlParameter("paramGuidMessageToMobile", OdDbType.Text, POut.StringParam(asapComm.GuidMessageToMobile)); if (useExistingPK || isRandomKeys) { Db.NonQ(command, paramTemplateText, paramTemplateEmail, paramNote, paramGuidMessageToMobile); } else { asapComm.AsapCommNum = Db.NonQ(command, true, "AsapCommNum", "asapComm", paramTemplateText, paramTemplateEmail, paramNote, paramGuidMessageToMobile); } return(asapComm.AsapCommNum); }
///<summary>Inserts one Job into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(Job job, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO job ("; if (!useExistingPK && isRandomKeys) { job.JobNum = ReplicationServers.GetKeyNoCache("job", "JobNum"); } if (isRandomKeys || useExistingPK) { command += "JobNum,"; } command += "UserNumConcept,UserNumExpert,UserNumEngineer,UserNumApproverConcept,UserNumApproverJob,UserNumApproverChange,UserNumDocumenter,UserNumCustContact,UserNumCheckout,UserNumInfo,ParentNum,DateTimeCustContact,Priority,Category,JobVersion,TimeEstimateDevelopment,TimeActual,DateTimeEntry,Implementation,Documentation,Title,PhaseCur,IsApprovalNeeded,AckDateTime,UserNumQuoter,UserNumApproverQuote,UserNumCustQuote,Requirements,UserNumTester,PriorityTesting,DateTimeTested,TimeEstimateConcept,TimeEstimateWriteup,TimeEstimateReview,RequirementsJSON,PatternReviewProject,PatternReviewStatus,ProposedVersion,DateTimeConceptApproval,DateTimeJobApproval,DateTimeImplemented,TimeTesting,IsNotTested) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(job.JobNum) + ","; } command += POut.Long(job.UserNumConcept) + "," + POut.Long(job.UserNumExpert) + "," + POut.Long(job.UserNumEngineer) + "," + POut.Long(job.UserNumApproverConcept) + "," + POut.Long(job.UserNumApproverJob) + "," + POut.Long(job.UserNumApproverChange) + "," + POut.Long(job.UserNumDocumenter) + "," + POut.Long(job.UserNumCustContact) + "," + POut.Long(job.UserNumCheckout) + "," + POut.Long(job.UserNumInfo) + "," + POut.Long(job.ParentNum) + "," + POut.DateT(job.DateTimeCustContact) + "," + POut.Long(job.Priority) + "," + "'" + POut.String(job.Category.ToString()) + "'," + "'" + POut.String(job.JobVersion) + "'," + "'" + POut.Long(job.TimeEstimateDevelopment.Ticks) + "'," + "'" + POut.Long(job.TimeActual.Ticks) + "'," + DbHelper.Now() + "," + DbHelper.ParamChar + "paramImplementation," + DbHelper.ParamChar + "paramDocumentation," + "'" + POut.String(job.Title) + "'," + "'" + POut.String(job.PhaseCur.ToString()) + "'," + POut.Bool(job.IsApprovalNeeded) + "," + POut.DateT(job.AckDateTime) + "," + POut.Long(job.UserNumQuoter) + "," + POut.Long(job.UserNumApproverQuote) + "," + POut.Long(job.UserNumCustQuote) + "," + DbHelper.ParamChar + "paramRequirements," + POut.Long(job.UserNumTester) + "," + POut.Long(job.PriorityTesting) + "," + POut.DateT(job.DateTimeTested) + "," + "'" + POut.Long(job.TimeEstimateConcept.Ticks) + "'," + "'" + POut.Long(job.TimeEstimateWriteup.Ticks) + "'," + "'" + POut.Long(job.TimeEstimateReview.Ticks) + "'," + DbHelper.ParamChar + "paramRequirementsJSON," + POut.Int((int)job.PatternReviewProject) + "," + POut.Int((int)job.PatternReviewStatus) + "," + POut.Int((int)job.ProposedVersion) + "," + POut.DateT(job.DateTimeConceptApproval) + "," + POut.DateT(job.DateTimeJobApproval) + "," + POut.DateT(job.DateTimeImplemented) + "," + "'" + POut.Long(job.TimeTesting.Ticks) + "'," + POut.Bool(job.IsNotTested) + ")"; if (job.Implementation == null) { job.Implementation = ""; } OdSqlParameter paramImplementation = new OdSqlParameter("paramImplementation", OdDbType.Text, POut.StringParam(job.Implementation)); if (job.Documentation == null) { job.Documentation = ""; } OdSqlParameter paramDocumentation = new OdSqlParameter("paramDocumentation", OdDbType.Text, POut.StringParam(job.Documentation)); if (job.Requirements == null) { job.Requirements = ""; } OdSqlParameter paramRequirements = new OdSqlParameter("paramRequirements", OdDbType.Text, POut.StringParam(job.Requirements)); if (job.RequirementsJSON == null) { job.RequirementsJSON = ""; } OdSqlParameter paramRequirementsJSON = new OdSqlParameter("paramRequirementsJSON", OdDbType.Text, POut.StringParam(job.RequirementsJSON)); if (useExistingPK || isRandomKeys) { Db.NonQ(command, paramImplementation, paramDocumentation, paramRequirements, paramRequirementsJSON); } else { job.JobNum = Db.NonQ(command, true, "JobNum", "job", paramImplementation, paramDocumentation, paramRequirements, paramRequirementsJSON); } return(job.JobNum); }
///<summary>Updates one AsapComm in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(AsapComm asapComm, AsapComm oldAsapComm) { string command = ""; if (asapComm.FKey != oldAsapComm.FKey) { if (command != "") { command += ","; } command += "FKey = " + POut.Long(asapComm.FKey) + ""; } if (asapComm.FKeyType != oldAsapComm.FKeyType) { if (command != "") { command += ","; } command += "FKeyType = " + POut.Int((int)asapComm.FKeyType) + ""; } if (asapComm.ScheduleNum != oldAsapComm.ScheduleNum) { if (command != "") { command += ","; } command += "ScheduleNum = " + POut.Long(asapComm.ScheduleNum) + ""; } if (asapComm.PatNum != oldAsapComm.PatNum) { if (command != "") { command += ","; } command += "PatNum = " + POut.Long(asapComm.PatNum) + ""; } if (asapComm.ClinicNum != oldAsapComm.ClinicNum) { if (command != "") { command += ","; } command += "ClinicNum = " + POut.Long(asapComm.ClinicNum) + ""; } if (asapComm.ShortGUID != oldAsapComm.ShortGUID) { if (command != "") { command += ","; } command += "ShortGUID = '" + POut.String(asapComm.ShortGUID) + "'"; } //DateTimeEntry not allowed to change if (asapComm.DateTimeExpire != oldAsapComm.DateTimeExpire) { if (command != "") { command += ","; } command += "DateTimeExpire = " + POut.DateT(asapComm.DateTimeExpire) + ""; } if (asapComm.DateTimeSmsScheduled != oldAsapComm.DateTimeSmsScheduled) { if (command != "") { command += ","; } command += "DateTimeSmsScheduled = " + POut.DateT(asapComm.DateTimeSmsScheduled) + ""; } if (asapComm.SmsSendStatus != oldAsapComm.SmsSendStatus) { if (command != "") { command += ","; } command += "SmsSendStatus = " + POut.Int((int)asapComm.SmsSendStatus) + ""; } if (asapComm.EmailSendStatus != oldAsapComm.EmailSendStatus) { if (command != "") { command += ","; } command += "EmailSendStatus = " + POut.Int((int)asapComm.EmailSendStatus) + ""; } if (asapComm.DateTimeSmsSent != oldAsapComm.DateTimeSmsSent) { if (command != "") { command += ","; } command += "DateTimeSmsSent = " + POut.DateT(asapComm.DateTimeSmsSent) + ""; } if (asapComm.DateTimeEmailSent != oldAsapComm.DateTimeEmailSent) { if (command != "") { command += ","; } command += "DateTimeEmailSent = " + POut.DateT(asapComm.DateTimeEmailSent) + ""; } if (asapComm.EmailMessageNum != oldAsapComm.EmailMessageNum) { if (command != "") { command += ","; } command += "EmailMessageNum = " + POut.Long(asapComm.EmailMessageNum) + ""; } if (asapComm.ResponseStatus != oldAsapComm.ResponseStatus) { if (command != "") { command += ","; } command += "ResponseStatus = " + POut.Int((int)asapComm.ResponseStatus) + ""; } if (asapComm.DateTimeOrig != oldAsapComm.DateTimeOrig) { if (command != "") { command += ","; } command += "DateTimeOrig = " + POut.DateT(asapComm.DateTimeOrig) + ""; } if (asapComm.TemplateText != oldAsapComm.TemplateText) { if (command != "") { command += ","; } command += "TemplateText = " + DbHelper.ParamChar + "paramTemplateText"; } if (asapComm.TemplateEmail != oldAsapComm.TemplateEmail) { if (command != "") { command += ","; } command += "TemplateEmail = " + DbHelper.ParamChar + "paramTemplateEmail"; } if (asapComm.TemplateEmailSubj != oldAsapComm.TemplateEmailSubj) { if (command != "") { command += ","; } command += "TemplateEmailSubj = '" + POut.String(asapComm.TemplateEmailSubj) + "'"; } if (asapComm.Note != oldAsapComm.Note) { if (command != "") { command += ","; } command += "Note = " + DbHelper.ParamChar + "paramNote"; } if (asapComm.GuidMessageToMobile != oldAsapComm.GuidMessageToMobile) { if (command != "") { command += ","; } command += "GuidMessageToMobile = " + DbHelper.ParamChar + "paramGuidMessageToMobile"; } if (command == "") { return(false); } if (asapComm.TemplateText == null) { asapComm.TemplateText = ""; } OdSqlParameter paramTemplateText = new OdSqlParameter("paramTemplateText", OdDbType.Text, POut.StringParam(asapComm.TemplateText)); if (asapComm.TemplateEmail == null) { asapComm.TemplateEmail = ""; } OdSqlParameter paramTemplateEmail = new OdSqlParameter("paramTemplateEmail", OdDbType.Text, POut.StringParam(asapComm.TemplateEmail)); if (asapComm.Note == null) { asapComm.Note = ""; } OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(asapComm.Note)); if (asapComm.GuidMessageToMobile == null) { asapComm.GuidMessageToMobile = ""; } OdSqlParameter paramGuidMessageToMobile = new OdSqlParameter("paramGuidMessageToMobile", OdDbType.Text, POut.StringParam(asapComm.GuidMessageToMobile)); command = "UPDATE asapcomm SET " + command + " WHERE AsapCommNum = " + POut.Long(asapComm.AsapCommNum); Db.NonQ(command, paramTemplateText, paramTemplateEmail, paramNote, paramGuidMessageToMobile); return(true); }
///<summary>Updates one Job in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(Job job, Job oldJob) { string command = ""; if (job.UserNumConcept != oldJob.UserNumConcept) { if (command != "") { command += ","; } command += "UserNumConcept = " + POut.Long(job.UserNumConcept) + ""; } if (job.UserNumExpert != oldJob.UserNumExpert) { if (command != "") { command += ","; } command += "UserNumExpert = " + POut.Long(job.UserNumExpert) + ""; } if (job.UserNumEngineer != oldJob.UserNumEngineer) { if (command != "") { command += ","; } command += "UserNumEngineer = " + POut.Long(job.UserNumEngineer) + ""; } if (job.UserNumApproverConcept != oldJob.UserNumApproverConcept) { if (command != "") { command += ","; } command += "UserNumApproverConcept = " + POut.Long(job.UserNumApproverConcept) + ""; } if (job.UserNumApproverJob != oldJob.UserNumApproverJob) { if (command != "") { command += ","; } command += "UserNumApproverJob = " + POut.Long(job.UserNumApproverJob) + ""; } if (job.UserNumApproverChange != oldJob.UserNumApproverChange) { if (command != "") { command += ","; } command += "UserNumApproverChange = " + POut.Long(job.UserNumApproverChange) + ""; } if (job.UserNumDocumenter != oldJob.UserNumDocumenter) { if (command != "") { command += ","; } command += "UserNumDocumenter = " + POut.Long(job.UserNumDocumenter) + ""; } if (job.UserNumCustContact != oldJob.UserNumCustContact) { if (command != "") { command += ","; } command += "UserNumCustContact = " + POut.Long(job.UserNumCustContact) + ""; } if (job.UserNumCheckout != oldJob.UserNumCheckout) { if (command != "") { command += ","; } command += "UserNumCheckout = " + POut.Long(job.UserNumCheckout) + ""; } if (job.UserNumInfo != oldJob.UserNumInfo) { if (command != "") { command += ","; } command += "UserNumInfo = " + POut.Long(job.UserNumInfo) + ""; } if (job.ParentNum != oldJob.ParentNum) { if (command != "") { command += ","; } command += "ParentNum = " + POut.Long(job.ParentNum) + ""; } if (job.DateTimeCustContact != oldJob.DateTimeCustContact) { if (command != "") { command += ","; } command += "DateTimeCustContact = " + POut.DateT(job.DateTimeCustContact) + ""; } if (job.Priority != oldJob.Priority) { if (command != "") { command += ","; } command += "Priority = " + POut.Long(job.Priority) + ""; } if (job.Category != oldJob.Category) { if (command != "") { command += ","; } command += "Category = '" + POut.String(job.Category.ToString()) + "'"; } if (job.JobVersion != oldJob.JobVersion) { if (command != "") { command += ","; } command += "JobVersion = '" + POut.String(job.JobVersion) + "'"; } if (job.TimeEstimateDevelopment != oldJob.TimeEstimateDevelopment) { if (command != "") { command += ","; } command += "TimeEstimateDevelopment = '" + POut.Long(job.TimeEstimateDevelopment.Ticks) + "'"; } if (job.TimeActual != oldJob.TimeActual) { if (command != "") { command += ","; } command += "TimeActual = '" + POut.Long(job.TimeActual.Ticks) + "'"; } //DateTimeEntry not allowed to change if (job.Implementation != oldJob.Implementation) { if (command != "") { command += ","; } command += "Implementation = " + DbHelper.ParamChar + "paramImplementation"; } if (job.Documentation != oldJob.Documentation) { if (command != "") { command += ","; } command += "Documentation = " + DbHelper.ParamChar + "paramDocumentation"; } if (job.Title != oldJob.Title) { if (command != "") { command += ","; } command += "Title = '" + POut.String(job.Title) + "'"; } if (job.PhaseCur != oldJob.PhaseCur) { if (command != "") { command += ","; } command += "PhaseCur = '" + POut.String(job.PhaseCur.ToString()) + "'"; } if (job.IsApprovalNeeded != oldJob.IsApprovalNeeded) { if (command != "") { command += ","; } command += "IsApprovalNeeded = " + POut.Bool(job.IsApprovalNeeded) + ""; } if (job.AckDateTime != oldJob.AckDateTime) { if (command != "") { command += ","; } command += "AckDateTime = " + POut.DateT(job.AckDateTime) + ""; } if (job.UserNumQuoter != oldJob.UserNumQuoter) { if (command != "") { command += ","; } command += "UserNumQuoter = " + POut.Long(job.UserNumQuoter) + ""; } if (job.UserNumApproverQuote != oldJob.UserNumApproverQuote) { if (command != "") { command += ","; } command += "UserNumApproverQuote = " + POut.Long(job.UserNumApproverQuote) + ""; } if (job.UserNumCustQuote != oldJob.UserNumCustQuote) { if (command != "") { command += ","; } command += "UserNumCustQuote = " + POut.Long(job.UserNumCustQuote) + ""; } if (job.Requirements != oldJob.Requirements) { if (command != "") { command += ","; } command += "Requirements = " + DbHelper.ParamChar + "paramRequirements"; } if (job.UserNumTester != oldJob.UserNumTester) { if (command != "") { command += ","; } command += "UserNumTester = " + POut.Long(job.UserNumTester) + ""; } if (job.PriorityTesting != oldJob.PriorityTesting) { if (command != "") { command += ","; } command += "PriorityTesting = " + POut.Long(job.PriorityTesting) + ""; } if (job.DateTimeTested != oldJob.DateTimeTested) { if (command != "") { command += ","; } command += "DateTimeTested = " + POut.DateT(job.DateTimeTested) + ""; } if (job.TimeEstimateConcept != oldJob.TimeEstimateConcept) { if (command != "") { command += ","; } command += "TimeEstimateConcept = '" + POut.Long(job.TimeEstimateConcept.Ticks) + "'"; } if (job.TimeEstimateWriteup != oldJob.TimeEstimateWriteup) { if (command != "") { command += ","; } command += "TimeEstimateWriteup = '" + POut.Long(job.TimeEstimateWriteup.Ticks) + "'"; } if (job.TimeEstimateReview != oldJob.TimeEstimateReview) { if (command != "") { command += ","; } command += "TimeEstimateReview = '" + POut.Long(job.TimeEstimateReview.Ticks) + "'"; } if (job.RequirementsJSON != oldJob.RequirementsJSON) { if (command != "") { command += ","; } command += "RequirementsJSON = " + DbHelper.ParamChar + "paramRequirementsJSON"; } if (job.PatternReviewProject != oldJob.PatternReviewProject) { if (command != "") { command += ","; } command += "PatternReviewProject = " + POut.Int((int)job.PatternReviewProject) + ""; } if (job.PatternReviewStatus != oldJob.PatternReviewStatus) { if (command != "") { command += ","; } command += "PatternReviewStatus = " + POut.Int((int)job.PatternReviewStatus) + ""; } if (job.ProposedVersion != oldJob.ProposedVersion) { if (command != "") { command += ","; } command += "ProposedVersion = " + POut.Int((int)job.ProposedVersion) + ""; } if (job.DateTimeConceptApproval != oldJob.DateTimeConceptApproval) { if (command != "") { command += ","; } command += "DateTimeConceptApproval = " + POut.DateT(job.DateTimeConceptApproval) + ""; } if (job.DateTimeJobApproval != oldJob.DateTimeJobApproval) { if (command != "") { command += ","; } command += "DateTimeJobApproval = " + POut.DateT(job.DateTimeJobApproval) + ""; } if (job.DateTimeImplemented != oldJob.DateTimeImplemented) { if (command != "") { command += ","; } command += "DateTimeImplemented = " + POut.DateT(job.DateTimeImplemented) + ""; } if (job.TimeTesting != oldJob.TimeTesting) { if (command != "") { command += ","; } command += "TimeTesting = '" + POut.Long(job.TimeTesting.Ticks) + "'"; } if (job.IsNotTested != oldJob.IsNotTested) { if (command != "") { command += ","; } command += "IsNotTested = " + POut.Bool(job.IsNotTested) + ""; } if (command == "") { return(false); } if (job.Implementation == null) { job.Implementation = ""; } OdSqlParameter paramImplementation = new OdSqlParameter("paramImplementation", OdDbType.Text, POut.StringParam(job.Implementation)); if (job.Documentation == null) { job.Documentation = ""; } OdSqlParameter paramDocumentation = new OdSqlParameter("paramDocumentation", OdDbType.Text, POut.StringParam(job.Documentation)); if (job.Requirements == null) { job.Requirements = ""; } OdSqlParameter paramRequirements = new OdSqlParameter("paramRequirements", OdDbType.Text, POut.StringParam(job.Requirements)); if (job.RequirementsJSON == null) { job.RequirementsJSON = ""; } OdSqlParameter paramRequirementsJSON = new OdSqlParameter("paramRequirementsJSON", OdDbType.Text, POut.StringParam(job.RequirementsJSON)); command = "UPDATE job SET " + command + " WHERE JobNum = " + POut.Long(job.JobNum); Db.NonQ(command, paramImplementation, paramDocumentation, paramRequirements, paramRequirementsJSON); return(true); }
///<summary>Inserts many UserWebs into the database. Provides option to use the existing priKey.</summary> public static void InsertMany(List <UserWeb> listUserWebs, bool useExistingPK) { if (!useExistingPK && PrefC.RandomKeys) { foreach (UserWeb userWeb in listUserWebs) { Insert(userWeb); } } else { StringBuilder sbCommands = null; int index = 0; int countRows = 0; while (index < listUserWebs.Count) { UserWeb userWeb = listUserWebs[index]; StringBuilder sbRow = new StringBuilder("("); bool hasComma = false; if (sbCommands == null) { sbCommands = new StringBuilder(); sbCommands.Append("INSERT INTO userweb ("); if (useExistingPK) { sbCommands.Append("UserWebNum,"); } sbCommands.Append("FKey,FKeyType,UserName,Password,PasswordResetCode,RequireUserNameChange,DateTimeLastLogin,RequirePasswordChange) VALUES "); countRows = 0; } else { hasComma = true; } if (useExistingPK) { sbRow.Append(POut.Long(userWeb.UserWebNum)); sbRow.Append(","); } sbRow.Append(POut.Long(userWeb.FKey)); sbRow.Append(","); sbRow.Append(POut.Int((int)userWeb.FKeyType)); sbRow.Append(","); sbRow.Append("'" + POut.String(userWeb.UserName) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(userWeb.Password) + "'"); sbRow.Append(","); sbRow.Append("'" + POut.String(userWeb.PasswordResetCode) + "'"); sbRow.Append(","); sbRow.Append(POut.Bool(userWeb.RequireUserNameChange)); sbRow.Append(","); sbRow.Append(POut.DateT(userWeb.DateTimeLastLogin)); sbRow.Append(","); sbRow.Append(POut.Bool(userWeb.RequirePasswordChange)); sbRow.Append(")"); if (sbCommands.Length + sbRow.Length + 1 > TableBase.MaxAllowedPacketCount && countRows > 0) { Db.NonQ(sbCommands.ToString()); sbCommands = null; } else { if (hasComma) { sbCommands.Append(","); } sbCommands.Append(sbRow.ToString()); countRows++; if (index == listUserWebs.Count - 1) { Db.NonQ(sbCommands.ToString()); } index++; } } } }
///<summary>Updates one SmsToMobile in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(SmsToMobile smsToMobile, SmsToMobile oldSmsToMobile) { string command = ""; if (smsToMobile.PatNum != oldSmsToMobile.PatNum) { if (command != "") { command += ","; } command += "PatNum = " + POut.Long(smsToMobile.PatNum) + ""; } if (smsToMobile.GuidMessage != oldSmsToMobile.GuidMessage) { if (command != "") { command += ","; } command += "GuidMessage = '" + POut.String(smsToMobile.GuidMessage) + "'"; } if (smsToMobile.GuidBatch != oldSmsToMobile.GuidBatch) { if (command != "") { command += ","; } command += "GuidBatch = '" + POut.String(smsToMobile.GuidBatch) + "'"; } if (smsToMobile.SmsPhoneNumber != oldSmsToMobile.SmsPhoneNumber) { if (command != "") { command += ","; } command += "SmsPhoneNumber = '" + POut.String(smsToMobile.SmsPhoneNumber) + "'"; } if (smsToMobile.MobilePhoneNumber != oldSmsToMobile.MobilePhoneNumber) { if (command != "") { command += ","; } command += "MobilePhoneNumber = '" + POut.String(smsToMobile.MobilePhoneNumber) + "'"; } if (smsToMobile.IsTimeSensitive != oldSmsToMobile.IsTimeSensitive) { if (command != "") { command += ","; } command += "IsTimeSensitive = " + POut.Bool(smsToMobile.IsTimeSensitive) + ""; } if (smsToMobile.MsgType != oldSmsToMobile.MsgType) { if (command != "") { command += ","; } command += "MsgType = " + POut.Int((int)smsToMobile.MsgType) + ""; } if (smsToMobile.MsgText != oldSmsToMobile.MsgText) { if (command != "") { command += ","; } command += "MsgText = " + DbHelper.ParamChar + "paramMsgText"; } if (smsToMobile.SmsStatus != oldSmsToMobile.SmsStatus) { if (command != "") { command += ","; } command += "SmsStatus = " + POut.Int((int)smsToMobile.SmsStatus) + ""; } if (smsToMobile.MsgParts != oldSmsToMobile.MsgParts) { if (command != "") { command += ","; } command += "MsgParts = " + POut.Int(smsToMobile.MsgParts) + ""; } if (smsToMobile.MsgChargeUSD != oldSmsToMobile.MsgChargeUSD) { if (command != "") { command += ","; } command += "MsgChargeUSD = " + POut.Float(smsToMobile.MsgChargeUSD) + ""; } if (smsToMobile.ClinicNum != oldSmsToMobile.ClinicNum) { if (command != "") { command += ","; } command += "ClinicNum = " + POut.Long(smsToMobile.ClinicNum) + ""; } if (smsToMobile.CustErrorText != oldSmsToMobile.CustErrorText) { if (command != "") { command += ","; } command += "CustErrorText = '" + POut.String(smsToMobile.CustErrorText) + "'"; } if (smsToMobile.DateTimeSent != oldSmsToMobile.DateTimeSent) { if (command != "") { command += ","; } command += "DateTimeSent = " + POut.DateT(smsToMobile.DateTimeSent) + ""; } if (smsToMobile.DateTimeTerminated != oldSmsToMobile.DateTimeTerminated) { if (command != "") { command += ","; } command += "DateTimeTerminated = " + POut.DateT(smsToMobile.DateTimeTerminated) + ""; } if (smsToMobile.IsHidden != oldSmsToMobile.IsHidden) { if (command != "") { command += ","; } command += "IsHidden = " + POut.Bool(smsToMobile.IsHidden) + ""; } if (smsToMobile.MsgDiscountUSD != oldSmsToMobile.MsgDiscountUSD) { if (command != "") { command += ","; } command += "MsgDiscountUSD = " + POut.Float(smsToMobile.MsgDiscountUSD) + ""; } //SecDateTEdit can only be set by MySQL if (command == "") { return(false); } if (smsToMobile.MsgText == null) { smsToMobile.MsgText = ""; } OdSqlParameter paramMsgText = new OdSqlParameter("paramMsgText", OdDbType.Text, POut.StringNote(smsToMobile.MsgText)); command = "UPDATE smstomobile SET " + command + " WHERE SmsToMobileNum = " + POut.Long(smsToMobile.SmsToMobileNum); Db.NonQ(command, paramMsgText); return(true); }
///<summary>Updates one UserWeb in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(UserWeb userWeb, UserWeb oldUserWeb) { string command = ""; if (userWeb.FKey != oldUserWeb.FKey) { if (command != "") { command += ","; } command += "FKey = " + POut.Long(userWeb.FKey) + ""; } if (userWeb.FKeyType != oldUserWeb.FKeyType) { if (command != "") { command += ","; } command += "FKeyType = " + POut.Int((int)userWeb.FKeyType) + ""; } if (userWeb.UserName != oldUserWeb.UserName) { if (command != "") { command += ","; } command += "UserName = '******'"; } if (userWeb.Password != oldUserWeb.Password) { if (command != "") { command += ","; } command += "Password = '******'"; } if (userWeb.PasswordResetCode != oldUserWeb.PasswordResetCode) { if (command != "") { command += ","; } command += "PasswordResetCode = '" + POut.String(userWeb.PasswordResetCode) + "'"; } if (userWeb.RequireUserNameChange != oldUserWeb.RequireUserNameChange) { if (command != "") { command += ","; } command += "RequireUserNameChange = " + POut.Bool(userWeb.RequireUserNameChange) + ""; } if (userWeb.DateTimeLastLogin != oldUserWeb.DateTimeLastLogin) { if (command != "") { command += ","; } command += "DateTimeLastLogin = "******""; } if (userWeb.RequirePasswordChange != oldUserWeb.RequirePasswordChange) { if (command != "") { command += ","; } command += "RequirePasswordChange = " + POut.Bool(userWeb.RequirePasswordChange) + ""; } if (command == "") { return(false); } command = "UPDATE userweb SET " + command + " WHERE UserWebNum = " + POut.Long(userWeb.UserWebNum); Db.NonQ(command); return(true); }
///<summary>Updates one LabCase in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables.</summary> internal static void Update(LabCase labCase, LabCase oldLabCase) { string command = ""; if (labCase.PatNum != oldLabCase.PatNum) { if (command != "") { command += ","; } command += "PatNum = " + POut.Long(labCase.PatNum) + ""; } if (labCase.LaboratoryNum != oldLabCase.LaboratoryNum) { if (command != "") { command += ","; } command += "LaboratoryNum = " + POut.Long(labCase.LaboratoryNum) + ""; } if (labCase.AptNum != oldLabCase.AptNum) { if (command != "") { command += ","; } command += "AptNum = " + POut.Long(labCase.AptNum) + ""; } if (labCase.PlannedAptNum != oldLabCase.PlannedAptNum) { if (command != "") { command += ","; } command += "PlannedAptNum = " + POut.Long(labCase.PlannedAptNum) + ""; } if (labCase.DateTimeDue != oldLabCase.DateTimeDue) { if (command != "") { command += ","; } command += "DateTimeDue = " + POut.DateT(labCase.DateTimeDue) + ""; } if (labCase.DateTimeCreated != oldLabCase.DateTimeCreated) { if (command != "") { command += ","; } command += "DateTimeCreated = " + POut.DateT(labCase.DateTimeCreated) + ""; } if (labCase.DateTimeSent != oldLabCase.DateTimeSent) { if (command != "") { command += ","; } command += "DateTimeSent = " + POut.DateT(labCase.DateTimeSent) + ""; } if (labCase.DateTimeRecd != oldLabCase.DateTimeRecd) { if (command != "") { command += ","; } command += "DateTimeRecd = " + POut.DateT(labCase.DateTimeRecd) + ""; } if (labCase.DateTimeChecked != oldLabCase.DateTimeChecked) { if (command != "") { command += ","; } command += "DateTimeChecked = " + POut.DateT(labCase.DateTimeChecked) + ""; } if (labCase.ProvNum != oldLabCase.ProvNum) { if (command != "") { command += ","; } command += "ProvNum = " + POut.Long(labCase.ProvNum) + ""; } if (labCase.Instructions != oldLabCase.Instructions) { if (command != "") { command += ","; } command += "Instructions = '" + POut.String(labCase.Instructions) + "'"; } if (labCase.LabFee != oldLabCase.LabFee) { if (command != "") { command += ","; } command += "LabFee = '" + POut.Double(labCase.LabFee) + "'"; } if (command == "") { return; } command = "UPDATE labcase SET " + command + " WHERE LabCaseNum = " + POut.Long(labCase.LabCaseNum); Db.NonQ(command); }
///<summary>Updates one TaskList in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables.</summary> internal static void Update(TaskList taskList, TaskList oldTaskList) { string command = ""; if (taskList.Descript != oldTaskList.Descript) { if (command != "") { command += ","; } command += "Descript = '" + POut.String(taskList.Descript) + "'"; } if (taskList.Parent != oldTaskList.Parent) { if (command != "") { command += ","; } command += "Parent = " + POut.Long(taskList.Parent) + ""; } if (taskList.DateTL != oldTaskList.DateTL) { if (command != "") { command += ","; } command += "DateTL = " + POut.Date(taskList.DateTL) + ""; } if (taskList.IsRepeating != oldTaskList.IsRepeating) { if (command != "") { command += ","; } command += "IsRepeating = " + POut.Bool(taskList.IsRepeating) + ""; } if (taskList.DateType != oldTaskList.DateType) { if (command != "") { command += ","; } command += "DateType = " + POut.Int((int)taskList.DateType) + ""; } if (taskList.FromNum != oldTaskList.FromNum) { if (command != "") { command += ","; } command += "FromNum = " + POut.Long(taskList.FromNum) + ""; } if (taskList.ObjectType != oldTaskList.ObjectType) { if (command != "") { command += ","; } command += "ObjectType = " + POut.Int((int)taskList.ObjectType) + ""; } if (taskList.DateTimeEntry != oldTaskList.DateTimeEntry) { if (command != "") { command += ","; } command += "DateTimeEntry = " + POut.DateT(taskList.DateTimeEntry) + ""; } if (command == "") { return; } command = "UPDATE tasklist SET " + command + " WHERE TaskListNum = " + POut.Long(taskList.TaskListNum); Db.NonQ(command); }
///<summary>Inserts one Document into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(Document document, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO document ("; if (!useExistingPK && isRandomKeys) { document.DocNum = ReplicationServers.GetKeyNoCache("document", "DocNum"); } if (isRandomKeys || useExistingPK) { command += "DocNum,"; } command += "Description,DateCreated,DocCategory,PatNum,FileName,ImgType,IsFlipped,DegreesRotated,ToothNumbers,Note,SigIsTopaz,Signature,CropX,CropY,CropW,CropH,WindowingMin,WindowingMax,MountItemNum,RawBase64,Thumbnail,ExternalGUID,ExternalSource) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(document.DocNum) + ","; } command += "'" + POut.String(document.Description) + "'," + POut.DateT(document.DateCreated) + "," + POut.Long(document.DocCategory) + "," + POut.Long(document.PatNum) + "," + "'" + POut.String(document.FileName) + "'," + POut.Int((int)document.ImgType) + "," + POut.Bool(document.IsFlipped) + "," + POut.Int(document.DegreesRotated) + "," + "'" + POut.String(document.ToothNumbers) + "'," + DbHelper.ParamChar + "paramNote," + POut.Bool(document.SigIsTopaz) + "," + DbHelper.ParamChar + "paramSignature," + POut.Int(document.CropX) + "," + POut.Int(document.CropY) + "," + POut.Int(document.CropW) + "," + POut.Int(document.CropH) + "," + POut.Int(document.WindowingMin) + "," + POut.Int(document.WindowingMax) + "," + POut.Long(document.MountItemNum) + "," //DateTStamp can only be set by MySQL + DbHelper.ParamChar + "paramRawBase64," + DbHelper.ParamChar + "paramThumbnail," + "'" + POut.String(document.ExternalGUID) + "'," + "'" + POut.String(document.ExternalSource.ToString()) + "')"; if (document.Note == null) { document.Note = ""; } OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(document.Note)); if (document.Signature == null) { document.Signature = ""; } OdSqlParameter paramSignature = new OdSqlParameter("paramSignature", OdDbType.Text, POut.StringParam(document.Signature)); if (document.RawBase64 == null) { document.RawBase64 = ""; } OdSqlParameter paramRawBase64 = new OdSqlParameter("paramRawBase64", OdDbType.Text, POut.StringParam(document.RawBase64)); if (document.Thumbnail == null) { document.Thumbnail = ""; } OdSqlParameter paramThumbnail = new OdSqlParameter("paramThumbnail", OdDbType.Text, POut.StringParam(document.Thumbnail)); if (useExistingPK || isRandomKeys) { Db.NonQ(command, paramNote, paramSignature, paramRawBase64, paramThumbnail); } else { document.DocNum = Db.NonQ(command, true, "DocNum", "document", paramNote, paramSignature, paramRawBase64, paramThumbnail); } return(document.DocNum); }
///<summary>Updates one LabResult in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(LabResult labResult, LabResult oldLabResult) { string command = ""; if (labResult.LabPanelNum != oldLabResult.LabPanelNum) { if (command != "") { command += ","; } command += "LabPanelNum = " + POut.Long(labResult.LabPanelNum) + ""; } if (labResult.DateTimeTest != oldLabResult.DateTimeTest) { if (command != "") { command += ","; } command += "DateTimeTest = " + POut.DateT(labResult.DateTimeTest) + ""; } if (labResult.TestName != oldLabResult.TestName) { if (command != "") { command += ","; } command += "TestName = '" + POut.String(labResult.TestName) + "'"; } //DateTStamp can only be set by MySQL if (labResult.TestID != oldLabResult.TestID) { if (command != "") { command += ","; } command += "TestID = '" + POut.String(labResult.TestID) + "'"; } if (labResult.ObsValue != oldLabResult.ObsValue) { if (command != "") { command += ","; } command += "ObsValue = '" + POut.String(labResult.ObsValue) + "'"; } if (labResult.ObsUnits != oldLabResult.ObsUnits) { if (command != "") { command += ","; } command += "ObsUnits = '" + POut.String(labResult.ObsUnits) + "'"; } if (labResult.ObsRange != oldLabResult.ObsRange) { if (command != "") { command += ","; } command += "ObsRange = '" + POut.String(labResult.ObsRange) + "'"; } if (labResult.AbnormalFlag != oldLabResult.AbnormalFlag) { if (command != "") { command += ","; } command += "AbnormalFlag = " + POut.Int((int)labResult.AbnormalFlag) + ""; } if (command == "") { return(false); } command = "UPDATE labresult SET " + command + " WHERE LabResultNum = " + POut.Long(labResult.LabResultNum); Db.NonQ(command); return(true); }