protected void bensubmitClick_Click(object sender, EventArgs e) { try { if (bensubmitClick.Text == "Update") { Int64 WSID = Convert.ToInt64(HiddwaterID.Value); DataTable Dt = TMSWatersupply.GetalredyexistWatersupply(WSID, null, null, ddlmonthw.SelectedValue, ddlyearw.SelectedValue, null, null, null, null, null, null, null, null).Tables[0]; if (Dt.Rows.Count > 0) { dvMsg.Visible = true; lblMessage.Text = "record already exists for entered month and year"; dvMsg.Attributes.Add("class", "error_msg"); return; } else { TMSWatersupply objelectricity = TMSWatersupply.Get(WSID); if (objelectricity != null) { objelectricity.WSBillAmount = Convert.ToDouble(txtwbillamount.Text); objelectricity.WSLateFees = Convert.ToDouble(txtwlatefee.Text); objelectricity.WSBillNumber = txtwbillno.Text; objelectricity.WSLastDate = txtDate2.SelectedDate; objelectricity.WSMonth = ddlmonthw.SelectedValue; objelectricity.WSYear = ddlyearw.SelectedValue; if (HidduploadeFile.Value == "") { if (FileuploadWater.FileName != "") { bool isExist2 = false; string strFatherFileNameWithPath2 = FileuploadWater.FileName; string strFatherExtensionName2 = System.IO.Path.GetExtension(strFatherFileNameWithPath2).ToLower(); string strFatherFileName2 = System.IO.Path.GetFileName(strFatherFileNameWithPath2).Replace(" ", "_"); if (strFatherExtensionName2.Equals(".jpg") || strFatherExtensionName2.Equals(".gif") || strFatherExtensionName2.Equals(".png") || strFatherExtensionName2.Equals(".jpeg") || strFatherExtensionName2.Equals(".bmp")) { string[] Name2 = strFatherFileName2.Split('.'); string Fname2 = Name2[0]; string ReplacFileName2 = Fname2 + "_" + DateTime.Now.ToString("yyyyMMddhhmmss") + strFatherExtensionName2; FileuploadWater.PostedFile.SaveAs(Server.MapPath(@"..\\Files\\" + ReplacFileName2)); objelectricity.WSExtra1 = "../Files/" + ReplacFileName2; } else { dvMsg.Visible = true; lblMessage.Text = "Please Upload .jpg,.gif,.png,.jpeg,.bmp File Only"; dvMsg.Attributes.Add("class", "error_msg"); return; } } } objelectricity.WSPaidStatus = ddlpaidstatuswater.SelectedValue; if (HiddPaud.Value == "Paid") { if (ddlpaidstatuswater.SelectedValue == "Unpaid") { } } else { if (ddlpaidstatuswater.SelectedValue == "Paid") { if (Convert.ToDateTime(objelectricity.WSLastDate) < DateTime.Now) { DateTime myDate1 = DateTime.Now; DateTime myDate2 = Convert.ToDateTime(objelectricity.WSLastDate); TimeSpan difference = myDate1.Subtract(myDate2); Double totalDays = Convert.ToDouble(difference.TotalDays); string ss = totalDays.ToString(); string[] one = ss.Split('.'); if (totalDays > 0) { Double SS = (Convert.ToDouble(objelectricity.WSLateFees) * Convert.ToDouble(one[0])); objelectricity.WSTotalAmount = (Convert.ToDouble(objelectricity.WSBillAmount) + SS); objelectricity.WSBillPaidDate = DateTime.Now; } } else { objelectricity.WSTotalAmount = Convert.ToDouble(objelectricity.WSBillAmount); objelectricity.WSBillPaidDate = DateTime.Now; } } } objelectricity.WSDate = DateTime.Now; objelectricity.WSStatus = 1; objelectricity.Update(); BindWaterSupply(); BindWYear(); SElecricity.Visible = false; SWater.Visible = true; Addelecricity.Visible = false; AddwaterSupply.Visible = false; aElectricSupply.Attributes.Add("class", ""); awaterSupply.Attributes.Add("class", "active"); dvMsg.Visible = true; lblMessage.Text = "Watrer Supply Bill Updated Successfully"; dvMsg.Attributes.Add("class", "warring_msg"); } } } else { TMSWatersupply objelectricity = new TMSWatersupply(); objelectricity.WSMonth = ddlmonthw.SelectedValue; objelectricity.WSYear = ddlyearw.SelectedValue; DataTable DtTMSWatersupply = TMSWatersupply.GetSearch(objelectricity).Tables[0]; if (DtTMSWatersupply.Rows.Count > 0) { dvMsg.Visible = true; lblMessage.Text = "record already exist For entered month and year"; dvMsg.Attributes.Add("class", "error_msg"); return; } else { objelectricity.WSBillAmount = Convert.ToDouble(txtwbillamount.Text); objelectricity.WSLateFees = Convert.ToDouble(txtwlatefee.Text); objelectricity.WSBillNumber = txtwbillno.Text; objelectricity.WSLastDate = txtDate2.SelectedDate; objelectricity.WSPaidStatus = "Unpaid"; objelectricity.WSDate = DateTime.Now; objelectricity.WSStatus = 1; if (FileuploadWater.FileName != "") { bool isExist2 = false; string strFatherFileNameWithPath2 = FileuploadWater.FileName; string strFatherExtensionName2 = System.IO.Path.GetExtension(strFatherFileNameWithPath2).ToLower(); string strFatherFileName2 = System.IO.Path.GetFileName(strFatherFileNameWithPath2).Replace(" ", "_"); if (strFatherExtensionName2.Equals(".jpg") || strFatherExtensionName2.Equals(".gif") || strFatherExtensionName2.Equals(".png") || strFatherExtensionName2.Equals(".jpeg") || strFatherExtensionName2.Equals(".bmp")) { string[] Name2 = strFatherFileName2.Split('.'); string Fname2 = Name2[0]; string ReplacFileName2 = Fname2 + "_" + DateTime.Now.ToString("yyyyMMddhhmmss") + strFatherExtensionName2; FileuploadWater.PostedFile.SaveAs(Server.MapPath(@"..\\Files\\" + ReplacFileName2)); objelectricity.WSExtra1 = "../Files/" + ReplacFileName2; } else { dvMsg.Visible = true; lblMessage.Text = "Please Upload .jpg,.gif,.png,.jpeg,.bmp File Only"; dvMsg.Attributes.Add("class", "error_msg"); return; } } objelectricity.Insert(); BindWaterSupply(); BindWYear(); SElecricity.Visible = false; SWater.Visible = true; Addelecricity.Visible = false; AddwaterSupply.Visible = false; aElectricSupply.Attributes.Add("class", ""); awaterSupply.Attributes.Add("class", "active"); dvMsg.Visible = true; lblMessage.Text = "Watrer Supply Bill Added Successfully"; dvMsg.Attributes.Add("class", "warring_msg"); } } } catch (Exception ex) { } }
public static void Update(TMSWatersupply tMSWatersupply, DbTransaction transaction) { tMSWatersupply.Update(transaction); }
public static void Update(TMSWatersupply tMSWatersupply) { tMSWatersupply.Update(); }