public static TMSWatersupply Get(System.Int64 wsWsid) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSWatersupply instance; instance = new TMSWatersupply(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSWatersupply_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, wsWsid); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) { throw new ApplicationException("Could not get TMSWatersupply ID:" + wsWsid.ToString() + " from Database."); } // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom(ds.Tables[0].Rows[0]); return(instance); }
protected void BindWaterSupply() { try { string wyear = null; if (ddlwater.SelectedValue != "-1") { wyear = ddlwater.SelectedValue; } else { wyear = null; } DataTable dtGriedViewWater = TMSWatersupply.GetWatersupplySEARCH(null, null, null, null, wyear, null, null, null, null, null, null).Tables[0]; if (dtGriedViewWater.Rows.Count > 0) { sectionSortWater.Visible = true; } else { sectionSortWater.Visible = false; } GrdWaterSupply.DataSource = dtGriedViewWater; GrdWaterSupply.DataBind(); } catch (Exception ex) { } }
protected void WaterEdit_Click(object sender, EventArgs e) { dvMsg.Visible = false; SElecricity.Visible = false; SWater.Visible = false; Addelecricity.Visible = false; AddwaterSupply.Visible = true; aElectricSupply.Attributes.Add("class", ""); awaterSupply.Attributes.Add("class", "active"); RequiredFieldValidator9.Visible = false; LinkButton lnkedite = (LinkButton)sender; lbladdw.Text = "Edit"; GridViewRow Grd = (GridViewRow)lnkedite.NamingContainer; Label lblWS_WSID = Grd.FindControl("lblWS_WSID") as Label; bensubmitClick.Text = "Update"; liWater1.Visible = true; Int64 WS_WSID = Convert.ToInt64(lblWS_WSID.Text); HiddwaterID.Value = lblWS_WSID.Text; TMSWatersupply objelectricity = TMSWatersupply.Get(WS_WSID); if (objelectricity != null) { txtwbillamount.Text = objelectricity.WSBillAmount.ToString(); txtwlatefee.Text = objelectricity.WSLateFees.ToString(); txtwbillno.Text = objelectricity.WSBillNumber; if (objelectricity.WSLastDate != null) { txtDate2.SelectedDate = objelectricity.WSLastDate; } ddlmonthw.SelectedValue = objelectricity.WSMonth; ddlyearw.SelectedValue = objelectricity.WSYear; ddlpaidstatuswater.SelectedValue = objelectricity.WSPaidStatus; HidduploadeFile.Value = ""; if (objelectricity.WSExtra1 != null) { Hyperwater.Visible = true; Hyperwater.NavigateUrl = objelectricity.WSExtra1; RequiredFieldValidator9.Visible = false; HidduploadeFile.Value = objelectricity.WSExtra1; } else { Hyperwater.Visible = false; } HiddPaud.Value = objelectricity.WSPaidStatus; } }
public static TMSWatersupply[] Search(System.Int64?wsWsid, System.Double?wsBillAmount, System.Double?wsLateFees, System.String wsMonth, System.String wsYear, System.DateTime?wsLastDate, System.DateTime?wsBillPaidDate, System.Double?wsTotalAmount, System.String wsPaidStatus, System.String wsBillNumber, System.String wsExtra1, System.DateTime?wsDate, System.Int32?wsStatus) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSWatersupply_SEARCH"; dbCommand = db.GetStoredProcCommand(sqlCommand, wsWsid, wsBillAmount, wsLateFees, wsMonth, wsYear, wsLastDate, wsBillPaidDate, wsTotalAmount, wsPaidStatus, wsBillNumber, wsExtra1, wsDate, wsStatus); ds = db.ExecuteDataSet(dbCommand); ds.Tables[0].TableName = TABLE_NAME; return(TMSWatersupply.MapFrom(ds)); }
public static TMSWatersupply[] MapFrom(DataSet ds) { List <TMSWatersupply> objects; // Initialise Collection. objects = new List <TMSWatersupply>(); // Validation. if (ds == null) { throw new ApplicationException("Cannot map to dataset null."); } else if (ds.Tables[TABLE_NAME].Rows.Count == 0) { return(objects.ToArray()); } if (ds.Tables[TABLE_NAME] == null) { throw new ApplicationException("Cannot find table [dbo].[TMS_Watersupply] in DataSet."); } if (ds.Tables[TABLE_NAME].Rows.Count < 1) { throw new ApplicationException("Table [dbo].[TMS_Watersupply] is empty."); } // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSWatersupply instance = new TMSWatersupply(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return(objects.ToArray()); }
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 DataSet GetSearch(TMSWatersupply searchObject) { return GetSearch(searchObject.WsWsid, searchObject.WSBillAmount, searchObject.WSLateFees, searchObject.WSMonth, searchObject.WSYear, searchObject.WSLastDate, searchObject.WSBillPaidDate, searchObject.WSTotalAmount, searchObject.WSPaidStatus, searchObject.WSBillNumber, searchObject.WSExtra1, searchObject.WSDate, searchObject.WSStatus); }
public static DataSet GetSearch(TMSWatersupply searchObject) { return(GetSearch(searchObject.WsWsid, searchObject.WSBillAmount, searchObject.WSLateFees, searchObject.WSMonth, searchObject.WSYear, searchObject.WSLastDate, searchObject.WSBillPaidDate, searchObject.WSTotalAmount, searchObject.WSPaidStatus, searchObject.WSBillNumber, searchObject.WSExtra1, searchObject.WSDate, searchObject.WSStatus)); }
public static void Update(TMSWatersupply tMSWatersupply, DbTransaction transaction) { tMSWatersupply.Update(transaction); }
public static void Update(TMSWatersupply tMSWatersupply) { tMSWatersupply.Update(); }
public static TMSWatersupply[] MapFrom(DataSet ds) { List<TMSWatersupply> objects; // Initialise Collection. objects = new List<TMSWatersupply>(); // Validation. if (ds == null) throw new ApplicationException("Cannot map to dataset null."); else if (ds.Tables[TABLE_NAME].Rows.Count == 0) return objects.ToArray(); if (ds.Tables[TABLE_NAME] == null) throw new ApplicationException("Cannot find table [dbo].[TMS_Watersupply] in DataSet."); if (ds.Tables[TABLE_NAME].Rows.Count < 1) throw new ApplicationException("Table [dbo].[TMS_Watersupply] is empty."); // Map DataSet to Instance. foreach (DataRow dr in ds.Tables[TABLE_NAME].Rows) { TMSWatersupply instance = new TMSWatersupply(); instance.MapFrom(dr); objects.Add(instance); } // Return collection. return objects.ToArray(); }
public static TMSWatersupply Get(System.Int64 wsWsid) { DataSet ds; Database db; string sqlCommand; DbCommand dbCommand; TMSWatersupply instance; instance = new TMSWatersupply(); db = DatabaseFactory.CreateDatabase(); sqlCommand = "[dbo].gspTMSWatersupply_SELECT"; dbCommand = db.GetStoredProcCommand(sqlCommand, wsWsid); // Get results. ds = db.ExecuteDataSet(dbCommand); // Verification. if (ds == null || ds.Tables[0].Rows.Count == 0) throw new ApplicationException("Could not get TMSWatersupply ID:" + wsWsid.ToString()+ " from Database."); // Return results. ds.Tables[0].TableName = TABLE_NAME; instance.MapFrom( ds.Tables[0].Rows[0] ); return instance; }