///<summary>Export a custom claim form. Even though we could probably allow this for internal claim forms as well, ///users can always copy over an internal claim form to a custom form and then export it.</summary> private void butExport_Click(object sender, System.EventArgs e) { if (gridCustom.GetSelectedIndex() == -1) { MsgBox.Show(this, "Please select a Custom Claim Form first."); return; } ClaimForm claimFormCur = (ClaimForm)gridCustom.Rows[gridCustom.GetSelectedIndex()].Tag; try { using (SaveFileDialog saveDlg = new SaveFileDialog()) { string filename = "ClaimForm" + claimFormCur.Description + ".xml"; saveDlg.InitialDirectory = PrefC.GetString(PrefName.ExportPath); saveDlg.FileName = filename; if (saveDlg.ShowDialog() != DialogResult.OK) { return; } XmlSerializer serializer = new XmlSerializer(typeof(ClaimForm)); using (TextWriter writer = new StreamWriter(saveDlg.FileName)) { serializer.Serialize(writer, claimFormCur); } } MsgBox.Show(this, "Exported"); } catch (Exception ex) { ex.DoNothing(); MsgBox.Show(this, "Export failed. This could be due to lack of permissions in the designated folder."); } }
///<summary>Inserts one ClaimForm into the database. Returns the new priKey.</summary> internal static long Insert(ClaimForm claimForm) { if(DataConnection.DBtype==DatabaseType.Oracle) { claimForm.ClaimFormNum=DbHelper.GetNextOracleKey("claimform","ClaimFormNum"); int loopcount=0; while(loopcount<100){ try { return Insert(claimForm,true); } catch(Oracle.DataAccess.Client.OracleException ex){ if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){ claimForm.ClaimFormNum++; loopcount++; } else{ throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return Insert(claimForm,false); } }
///<summary>Fills ListShort and ListLong with all claimforms from the db. Also attaches corresponding claimformitems to each.</summary> public static void Refresh() { string command = "SELECT * FROM claimform"; DataTable table = General.GetTable(command); ListLong = new ClaimForm[table.Rows.Count]; ArrayList tempAL = new ArrayList(); for (int i = 0; i < table.Rows.Count; i++) { ListLong[i] = new ClaimForm(); ListLong[i].ClaimFormNum = PIn.PInt(table.Rows[i][0].ToString()); ListLong[i].Description = PIn.PString(table.Rows[i][1].ToString()); ListLong[i].IsHidden = PIn.PBool(table.Rows[i][2].ToString()); ListLong[i].FontName = PIn.PString(table.Rows[i][3].ToString()); ListLong[i].FontSize = PIn.PFloat(table.Rows[i][4].ToString()); ListLong[i].UniqueID = PIn.PString(table.Rows[i][5].ToString()); ListLong[i].PrintImages = PIn.PBool(table.Rows[i][6].ToString()); ListLong[i].OffsetX = PIn.PInt(table.Rows[i][7].ToString()); ListLong[i].OffsetY = PIn.PInt(table.Rows[i][8].ToString()); ListLong[i].Items = ClaimFormItems.GetListForForm(ListLong[i].ClaimFormNum); if (!ListLong[i].IsHidden) { tempAL.Add(ListLong[i]); } } ListShort = new ClaimForm[tempAL.Count]; for (int i = 0; i < ListShort.Length; i++) { ListShort[i] = (ClaimForm)tempAL[i]; } }
///<summary>Inserts one ClaimForm into the database. Provides option to use the existing priKey.</summary> internal static long Insert(ClaimForm claimForm,bool useExistingPK) { if(!useExistingPK && PrefC.RandomKeys) { claimForm.ClaimFormNum=ReplicationServers.GetKey("claimform","ClaimFormNum"); } string command="INSERT INTO claimform ("; if(useExistingPK || PrefC.RandomKeys) { command+="ClaimFormNum,"; } command+="Description,IsHidden,FontName,FontSize,UniqueID,PrintImages,OffsetX,OffsetY) VALUES("; if(useExistingPK || PrefC.RandomKeys) { command+=POut.Long(claimForm.ClaimFormNum)+","; } command+= "'"+POut.String(claimForm.Description)+"'," + POut.Bool (claimForm.IsHidden)+"," +"'"+POut.String(claimForm.FontName)+"'," + POut.Float (claimForm.FontSize)+"," +"'"+POut.String(claimForm.UniqueID)+"'," + POut.Bool (claimForm.PrintImages)+"," + POut.Int (claimForm.OffsetX)+"," + POut.Int (claimForm.OffsetY)+")"; if(useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { claimForm.ClaimFormNum=Db.NonQ(command,true); } return claimForm.ClaimFormNum; }
///<summary>Updates all claimforms with this unique id including all attached items.</summary> public static void UpdateByUniqueID(ClaimForm cf) { //first get a list of the ClaimFormNums with this UniqueId string command = "SELECT ClaimFormNum FROM claimform WHERE UniqueID ='" + cf.UniqueID.ToString() + "'"; DataTable table = General.GetTable(command); int[] claimFormNums = new int[table.Rows.Count]; for (int i = 0; i < table.Rows.Count; i++) { claimFormNums[i] = PIn.PInt(table.Rows[i][0].ToString()); } //loop through each matching claimform for (int i = 0; i < claimFormNums.Length; i++) { cf.ClaimFormNum = claimFormNums[i]; Update(cf); command = "DELETE FROM claimformitem " + "WHERE ClaimFormNum = '" + POut.PInt(claimFormNums[i]) + "'"; General.NonQ(command); for (int j = 0; j < cf.Items.Length; j++) { cf.Items[j].ClaimFormNum = claimFormNums[i]; ClaimFormItems.Insert(cf.Items[j]); } } }
private void butCopy_Click(object sender, System.EventArgs e) { if (listClaimForms.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select an item first.")); return; } ClaimForm ClaimFormCur = ClaimForms.ListLong[listClaimForms.SelectedIndex].Copy(); long oldClaimFormNum = ClaimFormCur.ClaimFormNum; ClaimFormCur.UniqueID = ""; //designates it as a user added claimform ClaimForms.Insert(ClaimFormCur); //this duplicates the original claimform, but no items. long newClaimFormNum = ClaimFormCur.ClaimFormNum; //ClaimFormItems.GetListForForm(ClaimForms.ListLong[listClaimForms.SelectedIndex].ClaimFormNum); for (int i = 0; i < ClaimFormCur.Items.Length; i++) { //ClaimFormItems.Cur=ClaimFormItems.ListForForm[i]; ClaimFormCur.Items[i].ClaimFormNum = newClaimFormNum; ClaimFormItems.Insert(ClaimFormCur.Items[i]); } ClaimFormItems.RefreshCache(); changed = true; FillList(); }
///<summary> Called when cancelling out of creating a new claimform, and from the claimform window when clicking delete. Returns true if successful or false if dependencies found.</summary> public static bool Delete(ClaimForm cf) { //first, do dependency testing string command = "SELECT * FROM insplan WHERE claimformnum = '" + cf.ClaimFormNum.ToString() + "' "; if (FormChooseDatabase.DBtype == DatabaseType.Oracle) { command += "AND ROWNUM <= 1"; } else //Assume MySQL { command += "LIMIT 1"; } DataTable table = General.GetTable(command); if (table.Rows.Count == 1) { return(false); } //Then, delete the claimform command = "DELETE FROM claimform " + "WHERE ClaimFormNum = '" + POut.PInt(cf.ClaimFormNum) + "'"; General.NonQ(command); command = "DELETE FROM claimformitem " + "WHERE ClaimFormNum = '" + POut.PInt(cf.ClaimFormNum) + "'"; General.NonQ(command); return(true); }
private void butExport_Click(object sender, System.EventArgs e) { if (listClaimForms.SelectedIndex == -1) { MessageBox.Show(Lan.g(this, "Please select an item first.")); return; } ClaimForm ClaimFormCur = ClaimForms.ListLong[listClaimForms.SelectedIndex]; SaveFileDialog saveDlg = new SaveFileDialog(); string filename = "ClaimForm" + ClaimFormCur.Description + ".xml"; saveDlg.InitialDirectory = PrefC.GetString(PrefName.ExportPath); saveDlg.FileName = filename; if (saveDlg.ShowDialog() != DialogResult.OK) { return; } //MessageBox.Show(saveDlg.FileName); XmlSerializer serializer = new XmlSerializer(typeof(ClaimForm)); TextWriter writer = new StreamWriter(saveDlg.FileName); serializer.Serialize(writer, ClaimFormCur); writer.Close(); MessageBox.Show("Exported"); }
///<summary>Inserts one ClaimForm into the database. Returns the new priKey.</summary> public static long Insert(ClaimForm claimForm) { if (DataConnection.DBtype == DatabaseType.Oracle) { claimForm.ClaimFormNum = DbHelper.GetNextOracleKey("claimform", "ClaimFormNum"); int loopcount = 0; while (loopcount < 100) { try { return(Insert(claimForm, true)); } catch (Oracle.DataAccess.Client.OracleException ex) { if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")) { claimForm.ClaimFormNum++; loopcount++; } else { throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return(Insert(claimForm, false)); } }
private static void ProcessMessage(ClaimForm data, string connectionString, string tableName) { var processor = new ClaimValidationProcessor(connectionString, tableName); var record = processor.ProcessAsync(data); if (record != null) { // Place back into a processed queue } }
///<Summary>Can be called externally as part of the update sequence. Surround with try catch. Returns the ClaimFormNum of the new ClaimForm if it inserted a new claimform.</Summary> public static int ImportForm(string path, bool isUpdateSequence) { if (!File.Exists(path)) { throw new ApplicationException(Lan.g("FormClaimForm", "File does not exist.")); } ClaimForm tempClaimForm = new ClaimForm(); XmlSerializer serializer = new XmlSerializer(typeof(ClaimForm)); try{ using (TextReader reader = new StreamReader(path)){ tempClaimForm = (ClaimForm)serializer.Deserialize(reader); } } catch { throw new ApplicationException(Lan.g("FormClaimForm", "Invalid file format")); } int retVal = 0; bool isNew = true; if (tempClaimForm.UniqueID != "") //if it's blank, it's always inserted. { for (int i = 0; i < ClaimForms.ListLong.Length; i++) { if (ClaimForms.ListLong[i].UniqueID == tempClaimForm.UniqueID) { isNew = false; } } } if (isNew) { ClaimForms.Insert(tempClaimForm); //now we have a primary key. retVal = tempClaimForm.ClaimFormNum; for (int j = 0; j < tempClaimForm.Items.Length; j++) { tempClaimForm.Items[j].ClaimFormNum = tempClaimForm.ClaimFormNum; ClaimFormItems.Insert(tempClaimForm.Items[j]); } } else { if (!isUpdateSequence) { if (MessageBox.Show(tempClaimForm.Description + " already exists. Replace?", "", MessageBoxButtons.OKCancel) != DialogResult.OK) { return(0); } } ClaimForms.UpdateByUniqueID(tempClaimForm); } return(retVal); //only if uniqueID }
public IHttpActionResult PostInsuranceClaim(dynamic InsClaim) { if (InsClaim != null) { ClaimForm claimform = new ClaimForm(); try { int pnum = InsClaim.PolicyNo; int PolicyNumber = (from c in Db.InsuranceApplications where c.PolicyNo == pnum select c.PolicyNo).First(); dynamic PolicyNo = (from c in Db.ClaimForms where c.PolicyNo == PolicyNumber select c.PolicyNo).ToList(); if (PolicyNo.Count != 0) { return(Ok("Already Applied For Claim.")); } } catch { return(Ok("Policy number is incorrect")); } int Pnum = InsClaim.PolicyNo; claimform.PolicyNo = Pnum; claimform.CauseOfLoss = InsClaim.Causeofloss; claimform.dateOfLoss = InsClaim.Dateofloss; Db.ClaimForms.Add(claimform); Db.SaveChanges(); long ClaimNo = (from c in Db.ClaimForms where c.PolicyNo == Pnum select c.ClaimNo).FirstOrDefault(); dynamic Suminsured = (from i in Db.InsuranceApplications where i.PolicyNo == Pnum select i.SumInsured).FirstOrDefault(); dynamic Uid = (from i in Db.InsuranceApplications where i.PolicyNo == Pnum select i.UserID).FirstOrDefault(); int uid = Uid; dynamic BankAccountnumber = (from b in Db.BankDetails where b.UserID == uid select b.BankAccountNo).FirstOrDefault(); int?Ban = (int?)BankAccountnumber; int sum = Suminsured; return(Ok("Added Succesfully.Your Claim number is " + ClaimNo.ToString() + ". Please use this number for any further references when Admin Will Approve You will get Sum insurance amount of " + sum.ToString() + " In " + Ban.ToString() + " Bank accoount number.")); } else { return(Ok("Data is present")); } }
public static ClaimTableEntity ToEntity(this ClaimForm form) { var target = new ClaimTableEntity(); target.Description = form.Description; target.Id = form.Id; target.Images = form.Images; target.Label = form.Label; target.Name = form.Name; target.PolicyNumber = form.PolicyNumber; return(target); }
///<summary>Copy an internal form over to a new custom form.</summary> private void butCopy_Click(object sender, EventArgs e) { if (gridInternal.GetSelectedIndex() == -1) { MessageBox.Show(Lan.g(this, "Please select an item from the internal grid to copy over to the custom grid.")); return; } //just insert it into the db. ClaimForm claimFormInternal = (ClaimForm)gridInternal.Rows[gridInternal.GetSelectedIndex()].Tag; long claimFormNum = ClaimForms.Insert(claimFormInternal, true); FillGridCustom(); }
public async Task <ClaimTableEntity> ProcessAsync(ClaimForm claim) { var table = await TableStoreFactory.CreateAsync(this.connectionString, this.tableName); var provider = new TableStorageProvider(table); TableOperation retrieveOperation = TableOperation.Retrieve <ClaimTableEntity>(claim.Id.ToString(), claim.Id.ToString()); var result = await provider.QuerySingleAsync(retrieveOperation); var target = result.Result as ClaimTableEntity; return(target); }
///<summary>Sets a custom claim form as the default. We do not currently allow setting internal claim forms as default - users need to copy it over first.</summary> private void butDefault_Click(object sender, EventArgs e) { if (gridCustom.GetSelectedIndex() == -1) { MsgBox.Show(this, "Please select a claimform from the list first."); return; } ClaimForm claimFormCur = (ClaimForm)gridCustom.Rows[gridCustom.GetSelectedIndex()].Tag; if (Prefs.UpdateLong(PrefName.DefaultClaimForm, claimFormCur.ClaimFormNum)) { DataValid.SetInvalid(InvalidType.Prefs); } FillGridCustom(); }
public static Message CreateMessage(ClaimForm message) { if (message == null) { return(null); } var jsonContent = JsonConvert.SerializeObject(message); var msg = new Message(Encoding.UTF8.GetBytes(jsonContent)); msg.ContentType = "application/json"; msg.Label = message.Label; msg.TimeToLive = TimeSpan.FromSeconds(90); return(msg); }
///<summary>Inserts one ClaimForm into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(ClaimForm claimForm) { if (DataConnection.DBtype == DatabaseType.MySql) { return(InsertNoCache(claimForm, false)); } else { if (DataConnection.DBtype == DatabaseType.Oracle) { claimForm.ClaimFormNum = DbHelper.GetNextOracleKey("claimform", "ClaimFormNum"); //Cacheless method } return(InsertNoCache(claimForm, true)); } }
///<summary>Duplicate a custom claim form.</summary> private void butDuplicate_Click(object sender, System.EventArgs e) { if (gridCustom.GetSelectedIndex() == -1) { MsgBox.Show(this, "Please select a Custom Claim Form first."); return; } ClaimForm claimFormCur = (ClaimForm)gridCustom.Rows[gridCustom.GetSelectedIndex()].Tag; long oldClaimFormNum = claimFormCur.ClaimFormNum; //claimFormCur.UniqueID="";//designates it as a user added claimform ClaimForms.Insert(claimFormCur, true); //this duplicates the original claimform, but no items. changed = true; FillGridCustom(); }
///<summary>Updates one ClaimForm in the database.</summary> public static void Update(ClaimForm claimForm) { string command = "UPDATE claimform SET " + "Description = '" + POut.String(claimForm.Description) + "', " + "IsHidden = " + POut.Bool(claimForm.IsHidden) + ", " + "FontName = '" + POut.String(claimForm.FontName) + "', " + "FontSize = " + POut.Float(claimForm.FontSize) + ", " + "UniqueID = '" + POut.String(claimForm.UniqueID) + "', " + "PrintImages = " + POut.Bool(claimForm.PrintImages) + ", " + "OffsetX = " + POut.Int(claimForm.OffsetX) + ", " + "OffsetY = " + POut.Int(claimForm.OffsetY) + " " + "WHERE ClaimFormNum = " + POut.Long(claimForm.ClaimFormNum); Db.NonQ(command); }
///<summary></summary> public static void Update(ClaimForm cf) { string command = "UPDATE claimform SET " + "Description = '" + POut.PString(cf.Description) + "' " + ",IsHidden = '" + POut.PBool(cf.IsHidden) + "' " + ",FontName = '" + POut.PString(cf.FontName) + "' " + ",FontSize = '" + POut.PFloat(cf.FontSize) + "' " + ",UniqueID = '" + POut.PString(cf.UniqueID) + "' " + ",PrintImages = '" + POut.PBool(cf.PrintImages) + "' " + ",OffsetX = '" + POut.PInt(cf.OffsetX) + "' " + ",OffsetY = '" + POut.PInt(cf.OffsetY) + "' " + "WHERE ClaimFormNum = '" + POut.PInt(cf.ClaimFormNum) + "'"; General.NonQ(command); }
///<summary>Inserts this claimform into database and retrieves the new primary key.</summary> public static void Insert(ClaimForm cf) { string command = "INSERT INTO claimform (Description,IsHidden,FontName,FontSize" + ",UniqueId,PrintImages,OffsetX,OffsetY) VALUES(" + "'" + POut.PString(cf.Description) + "', " + "'" + POut.PBool(cf.IsHidden) + "', " + "'" + POut.PString(cf.FontName) + "', " + "'" + POut.PFloat(cf.FontSize) + "', " + "'" + POut.PString(cf.UniqueID) + "', " + "'" + POut.PBool(cf.PrintImages) + "', " + "'" + POut.PInt(cf.OffsetX) + "', " + "'" + POut.PInt(cf.OffsetY) + "')"; //MessageBox.Show(string command); cf.ClaimFormNum = General.NonQ(command, true); }
///<summary>Add a custom claim form.</summary> private void butAdd_Click(object sender, System.EventArgs e) { ClaimForm ClaimFormCur = new ClaimForm(); ClaimForms.Insert(ClaimFormCur, false); ClaimFormCur.IsNew = true; FormClaimFormEdit FormCFE = new FormClaimFormEdit(ClaimFormCur); FormCFE.ShowDialog(); if (FormCFE.DialogResult != DialogResult.OK) { return; } changed = true; FillGridCustom(); }
public IHttpActionResult PostClaimApproval(dynamic Num) { try { int NUM = Convert.ToInt32(Num); ClaimForm Cno = (from c in Db.ClaimForms where c.ClaimNo == NUM select c).First(); Cno.ClaimApprove = true; Db.Entry(Cno).State = EntityState.Modified; Db.SaveChanges(); return(Ok("Claim Request is Approved")); } catch (Exception e) { return(BadRequest(e.Message)); } }
///<summary>Converts a DataTable to a list of objects.</summary> public static List<ClaimForm> TableToList(DataTable table){ List<ClaimForm> retVal=new List<ClaimForm>(); ClaimForm claimForm; for(int i=0;i<table.Rows.Count;i++) { claimForm=new ClaimForm(); claimForm.ClaimFormNum= PIn.Long (table.Rows[i]["ClaimFormNum"].ToString()); claimForm.Description = PIn.String(table.Rows[i]["Description"].ToString()); claimForm.IsHidden = PIn.Bool (table.Rows[i]["IsHidden"].ToString()); claimForm.FontName = PIn.String(table.Rows[i]["FontName"].ToString()); claimForm.FontSize = PIn.Float (table.Rows[i]["FontSize"].ToString()); claimForm.UniqueID = PIn.String(table.Rows[i]["UniqueID"].ToString()); claimForm.PrintImages = PIn.Bool (table.Rows[i]["PrintImages"].ToString()); claimForm.OffsetX = PIn.Int (table.Rows[i]["OffsetX"].ToString()); claimForm.OffsetY = PIn.Int (table.Rows[i]["OffsetY"].ToString()); retVal.Add(claimForm); } return retVal; }
///<summary>Reassigns all current insurance plans using the selected claimform to another claimform.</summary> private void butReassign_Click(object sender, EventArgs e) { if (gridCustom.GetSelectedIndex() == -1) { MsgBox.Show(this, "Please select a claimform from the list at the left first."); return; } if (comboReassign.SelectedIndex == -1) { MsgBox.Show(this, "Please select a claimform from the list below."); return; } ClaimForm claimFormCur = (ClaimForm)gridCustom.Rows[gridCustom.GetSelectedIndex()].Tag; ClaimForm claimFormNew = ((ODBoxItem <ClaimForm>)comboReassign.SelectedItem).Tag; long result = ClaimForms.Reassign(claimFormCur.ClaimFormNum, claimFormNew.ClaimFormNum); MessageBox.Show(result.ToString() + Lan.g(this, " plans changed.")); }
private void butAdd_Click(object sender, System.EventArgs e) { ClaimForm ClaimFormCur = new ClaimForm(); ClaimForms.Insert(ClaimFormCur); FormClaimFormEdit FormCFE = new FormClaimFormEdit(); FormCFE.ClaimFormCur = ClaimFormCur; FormCFE.IsNew = true; FormCFE.ShowDialog(); if (FormCFE.DialogResult != DialogResult.OK) { return; } changed = true; //ClaimFormItems refreshed within FormCFE FillList(); }
///<summary>Returns true if Update(ClaimForm,ClaimForm) would make changes to the database. ///Does not make any changes to the database and can be called before remoting role is checked.</summary> public static bool UpdateComparison(ClaimForm claimForm, ClaimForm oldClaimForm) { if (claimForm.Description != oldClaimForm.Description) { return(true); } if (claimForm.IsHidden != oldClaimForm.IsHidden) { return(true); } if (claimForm.FontName != oldClaimForm.FontName) { return(true); } if (claimForm.FontSize != oldClaimForm.FontSize) { return(true); } if (claimForm.UniqueID != oldClaimForm.UniqueID) { return(true); } if (claimForm.PrintImages != oldClaimForm.PrintImages) { return(true); } if (claimForm.OffsetX != oldClaimForm.OffsetX) { return(true); } if (claimForm.OffsetY != oldClaimForm.OffsetY) { return(true); } if (claimForm.Width != oldClaimForm.Width) { return(true); } if (claimForm.Height != oldClaimForm.Height) { return(true); } return(false); }
///<summary>Delete an unusued custom claim form.</summary> private void butDelete_Click(object sender, System.EventArgs e) { if (gridCustom.GetSelectedIndex() == -1) { MessageBox.Show(Lan.g(this, "Please select a Custom Claim Form first.")); return; } ClaimForm claimFormCur = (ClaimForm)gridCustom.Rows[gridCustom.GetSelectedIndex()].Tag; if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete custom claim form?")) { return; } if (!ClaimForms.Delete(claimFormCur)) { MsgBox.Show(this, "Claim form is already in use."); return; } changed = true; FillGridCustom(); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <ClaimForm> TableToList(DataTable table) { List <ClaimForm> retVal = new List <ClaimForm>(); ClaimForm claimForm; for (int i = 0; i < table.Rows.Count; i++) { claimForm = new ClaimForm(); claimForm.ClaimFormNum = PIn.Long(table.Rows[i]["ClaimFormNum"].ToString()); claimForm.Description = PIn.String(table.Rows[i]["Description"].ToString()); claimForm.IsHidden = PIn.Bool(table.Rows[i]["IsHidden"].ToString()); claimForm.FontName = PIn.String(table.Rows[i]["FontName"].ToString()); claimForm.FontSize = PIn.Float(table.Rows[i]["FontSize"].ToString()); claimForm.UniqueID = PIn.String(table.Rows[i]["UniqueID"].ToString()); claimForm.PrintImages = PIn.Bool(table.Rows[i]["PrintImages"].ToString()); claimForm.OffsetX = PIn.Int(table.Rows[i]["OffsetX"].ToString()); claimForm.OffsetY = PIn.Int(table.Rows[i]["OffsetY"].ToString()); retVal.Add(claimForm); } return(retVal); }
///<summary>Inserts one ClaimForm into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(ClaimForm claimForm, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO claimform ("; if (!useExistingPK && isRandomKeys) { claimForm.ClaimFormNum = ReplicationServers.GetKeyNoCache("claimform", "ClaimFormNum"); } if (isRandomKeys || useExistingPK) { command += "ClaimFormNum,"; } command += "Description,IsHidden,FontName,FontSize,UniqueID,PrintImages,OffsetX,OffsetY,Width,Height) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(claimForm.ClaimFormNum) + ","; } command += "'" + POut.String(claimForm.Description) + "'," + POut.Bool(claimForm.IsHidden) + "," + "'" + POut.String(claimForm.FontName) + "'," + POut.Float(claimForm.FontSize) + "," + "'" + POut.String(claimForm.UniqueID) + "'," + POut.Bool(claimForm.PrintImages) + "," + POut.Int(claimForm.OffsetX) + "," + POut.Int(claimForm.OffsetY) + "," + POut.Int(claimForm.Width) + "," + POut.Int(claimForm.Height) + ")"; if (useExistingPK || isRandomKeys) { Db.NonQ(command); } else { claimForm.ClaimFormNum = Db.NonQ(command, true, "ClaimFormNum", "claimForm"); } return(claimForm.ClaimFormNum); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <ClaimForm> TableToList(DataTable table) { List <ClaimForm> retVal = new List <ClaimForm>(); ClaimForm claimForm; foreach (DataRow row in table.Rows) { claimForm = new ClaimForm(); claimForm.ClaimFormNum = PIn.Long(row["ClaimFormNum"].ToString()); claimForm.Description = PIn.String(row["Description"].ToString()); claimForm.IsHidden = PIn.Bool(row["IsHidden"].ToString()); claimForm.FontName = PIn.String(row["FontName"].ToString()); claimForm.FontSize = PIn.Float(row["FontSize"].ToString()); claimForm.UniqueID = PIn.String(row["UniqueID"].ToString()); claimForm.PrintImages = PIn.Bool(row["PrintImages"].ToString()); claimForm.OffsetX = PIn.Int(row["OffsetX"].ToString()); claimForm.OffsetY = PIn.Int(row["OffsetY"].ToString()); claimForm.Width = PIn.Int(row["Width"].ToString()); claimForm.Height = PIn.Int(row["Height"].ToString()); retVal.Add(claimForm); } return(retVal); }
///<summary>Inserts one ClaimForm into the database. Provides option to use the existing priKey.</summary> public static long Insert(ClaimForm claimForm, bool useExistingPK) { if (!useExistingPK && PrefC.RandomKeys) { claimForm.ClaimFormNum = ReplicationServers.GetKey("claimform", "ClaimFormNum"); } string command = "INSERT INTO claimform ("; if (useExistingPK || PrefC.RandomKeys) { command += "ClaimFormNum,"; } command += "Description,IsHidden,FontName,FontSize,UniqueID,PrintImages,OffsetX,OffsetY) VALUES("; if (useExistingPK || PrefC.RandomKeys) { command += POut.Long(claimForm.ClaimFormNum) + ","; } command += "'" + POut.String(claimForm.Description) + "'," + POut.Bool(claimForm.IsHidden) + "," + "'" + POut.String(claimForm.FontName) + "'," + POut.Float(claimForm.FontSize) + "," + "'" + POut.String(claimForm.UniqueID) + "'," + POut.Bool(claimForm.PrintImages) + "," + POut.Int(claimForm.OffsetX) + "," + POut.Int(claimForm.OffsetY) + ")"; if (useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { claimForm.ClaimFormNum = Db.NonQ(command, true); } return(claimForm.ClaimFormNum); }
///<summary>Updates one ClaimForm 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(ClaimForm claimForm,ClaimForm oldClaimForm){ string command=""; if(claimForm.Description != oldClaimForm.Description) { if(command!=""){ command+=",";} command+="Description = '"+POut.String(claimForm.Description)+"'"; } if(claimForm.IsHidden != oldClaimForm.IsHidden) { if(command!=""){ command+=",";} command+="IsHidden = "+POut.Bool(claimForm.IsHidden)+""; } if(claimForm.FontName != oldClaimForm.FontName) { if(command!=""){ command+=",";} command+="FontName = '"+POut.String(claimForm.FontName)+"'"; } if(claimForm.FontSize != oldClaimForm.FontSize) { if(command!=""){ command+=",";} command+="FontSize = "+POut.Float(claimForm.FontSize)+""; } if(claimForm.UniqueID != oldClaimForm.UniqueID) { if(command!=""){ command+=",";} command+="UniqueID = '"+POut.String(claimForm.UniqueID)+"'"; } if(claimForm.PrintImages != oldClaimForm.PrintImages) { if(command!=""){ command+=",";} command+="PrintImages = "+POut.Bool(claimForm.PrintImages)+""; } if(claimForm.OffsetX != oldClaimForm.OffsetX) { if(command!=""){ command+=",";} command+="OffsetX = "+POut.Int(claimForm.OffsetX)+""; } if(claimForm.OffsetY != oldClaimForm.OffsetY) { if(command!=""){ command+=",";} command+="OffsetY = "+POut.Int(claimForm.OffsetY)+""; } if(command==""){ return false; } command="UPDATE claimform SET "+command +" WHERE ClaimFormNum = "+POut.Long(claimForm.ClaimFormNum); Db.NonQ(command); return true; }
///<summary>Updates one ClaimForm in the database.</summary> public static void Update(ClaimForm claimForm){ string command="UPDATE claimform SET " +"Description = '"+POut.String(claimForm.Description)+"', " +"IsHidden = "+POut.Bool (claimForm.IsHidden)+", " +"FontName = '"+POut.String(claimForm.FontName)+"', " +"FontSize = "+POut.Float (claimForm.FontSize)+", " +"UniqueID = '"+POut.String(claimForm.UniqueID)+"', " +"PrintImages = "+POut.Bool (claimForm.PrintImages)+", " +"OffsetX = "+POut.Int (claimForm.OffsetX)+", " +"OffsetY = "+POut.Int (claimForm.OffsetY)+" " +"WHERE ClaimFormNum = "+POut.Long(claimForm.ClaimFormNum); Db.NonQ(command); }