private void frmCosting_Load(object sender, EventArgs e) { StockHoldingRate_DL objStockHoldingRateDL = new StockHoldingRate_DL(ConnectionStringClass.GetConnection()); Employee_DL objEmpDL = new Employee_DL(ConnectionStringClass.GetConnection()); Department_DL objDepDL = new Department_DL(ConnectionStringClass.GetConnection()); Section_DL objSection_DL = new Section_DL(ConnectionStringClass.GetConnection()); try { StockHoldingRate obj = new StockHoldingRate(); obj = objStockHoldingRateDL.GetFinal(); Employee objChangedBy = objEmpDL.Get(obj.ChangedBy); txtEnterdBy.Text = objChangedBy.EmployeeName; txtEnterdDate.Text = obj.FromDate.Value.ToShortDateString(); txtCurrentRate.Text = obj.Cost.ToString(); bindStockHolding.DataSource = objStockHoldingRateDL.Get(); bindDepartment.DataSource = objSection_DL.GetDataView(); objCompanyOverHeadRate = objCompanyOverHeadRate_DL.Get(); if (objCompanyOverHeadRate != null) { txtComDate.Text = objCompanyOverHeadRate.EnterdDate.ToShortDateString(); txtComEnterd.Text = objCompanyOverHeadRate.EnterdBy.EmployeeNameID; txtComRate.Text = objCompanyOverHeadRate.Rate.ToString(); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnComSave_Click(object sender, EventArgs e) { try { if (objCompanyOverHeadRate == null) { objCompanyOverHeadRate = new CompanyOverHeadRate(); } objCompanyOverHeadRate.Rate = Convert.ToDecimal(txtComRate.Text); objCompanyOverHeadRate.EnterdBy = CurrentUser.UserEmp; objCompanyOverHeadRate.EnterdDate = DateTime.Now; long id = objCompanyOverHeadRate_DL.Add(objCompanyOverHeadRate); if (id > 0) { objCompanyOverHeadRate.ID = id; } if (objCompanyOverHeadRate != null) { txtComDate.Text = objCompanyOverHeadRate.EnterdDate.ToShortDateString(); txtComEnterd.Text = objCompanyOverHeadRate.EnterdBy.EmployeeNameID; txtComRate.Text = objCompanyOverHeadRate.Rate.ToString(); } } catch (Exception) { MessageBox.Show(this, "Error occured while saving Company Overhead rate", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public long Add(CompanyOverHeadRate obj) { try { SqlParameter[] paramList = new SqlParameter[] { new SqlParameter("@ID", obj.ID), new SqlParameter("@Rate", obj.Rate), new SqlParameter("@EnteredBy", obj.EnterdBy.EmployeeID), new SqlParameter("@EnteredDate", obj.EnterdDate) }; return(Execute.RunSP_RowsEffected(Connection, "SPADD_CompanyOverHeadRate_Update", paramList)); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public CompanyOverHeadRate Get() { try { CompanyOverHeadRate obj = new CompanyOverHeadRate(); DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_OverheadRates"); obj.EnterdBy = objEmployee_DL.Get(Convert.ToString(dt.Rows[0]["EnterdBy"])); obj.EnterdDate = Convert.ToDateTime(dt.Rows[0]["Date"]); obj.ID = Convert.ToInt64(dt.Rows[0]["DepID"]); obj.Rate = Convert.ToDecimal(dt.Rows[0]["Rate"]); return(obj); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }