public OverheadRates Get(long DepID) { OverheadRates obj = new OverheadRates(); try { SqlParameter[] paramList = new SqlParameter[] { new SqlParameter("@DepID", DepID) }; DataTable dt= Execute.RunSP_DataTable(Connection, "SPGET_OverheadRates_By_DepID", paramList); obj.EnterdBy = Convert.ToString(dt.Rows[0]["EnterdBy"]); obj.EnterdDate = Convert.ToDateTime(dt.Rows[0]["Date"]); obj.SectionID = 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); } }
private void btnSaveDep_Click(object sender, EventArgs e) { try { Section_DL objSection_DL = new Section_DL(ConnectionStringClass.GetConnection()); Department_DL objDepDL = new Department_DL(ConnectionStringClass.GetConnection()); OverheadRates objOverheadRates = new OverheadRates(); OverheadRates_DL objOverheadRates_DL = new OverheadRates_DL(ConnectionStringClass.GetConnection()); Employee_DL objEmpDL = new Employee_DL(ConnectionStringClass.GetConnection()); if (objSelectedSections.DepID != 0) { Sections objSections = objSelectedSections; if (textBox1.Text != "") { if (objSections.DepID != 0) { objOverheadRates.SectionID = objSections.SectionID; objOverheadRates.EnterdBy = CurrentUser.EmployeeID; objOverheadRates.EnterdDate = DateTime.Now; objOverheadRates.Rate = Convert.ToDecimal(textBox1.Text); objOverheadRates_DL.Add(objOverheadRates); ClearDep(); bindDepartment.DataSource = objSection_DL.GetDataView(); } } else { MessageBox.Show(this, "Please enter a valid Overhead Rate", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show(this, "Please Select a Department from the list", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception) { MessageBox.Show(this, "Error occured while saving overhead rate", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public int Add(OverheadRates obj) { try { SqlParameter[] paramList = new SqlParameter[] { new SqlParameter("@DepID", obj.SectionID), new SqlParameter("@Rate", obj.Rate), new SqlParameter("@EnterdBy", obj.EnterdBy), new SqlParameter("@Date", obj.EnterdDate) }; return Execute.RunSP_RowsEffected(Connection, "SPADD_OverheadRates", paramList); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
private void gvDepartment_CellClick(object sender, DataGridViewCellEventArgs e) { try { Department_DL objDepDL = new Department_DL(ConnectionStringClass.GetConnection()); Section_DL objSection_DL = new Section_DL(ConnectionStringClass.GetConnection()); OverheadRates objOverheadRates = new OverheadRates(); OverheadRates_DL objOverheadRates_DL = new OverheadRates_DL(ConnectionStringClass.GetConnection()); Employee_DL objEmpDL = new Employee_DL(ConnectionStringClass.GetConnection()); ClearDep(); if (true) { Sections objSection = objSection_DL.Get(Convert.ToInt64(gvDepartment.Rows[e.RowIndex].Cells["colDepID"].Value)); Department objDep = objDepDL.Get(objSection.DepID); if (objDep.DepID != 0) { txtSection.Text = objSection.SectionName; objSelectedSections = objSection; txtDID.Text = objDep.DepID.ToString(); txtDepartmentName.Text = objDep.DepName; objOverheadRates = objOverheadRates_DL.Get(objSection.SectionID); if (objOverheadRates.SectionID != 0) { txtDepCurrent.Text = objOverheadRates.Rate.ToString(); Employee objEmp = objEmpDL.Get(objOverheadRates.EnterdBy); txtDepEnterdBy.Text = objEmp.EmployeeName; txtDepEnterdDate.Text = objOverheadRates.EnterdDate.ToShortDateString(); } } } } catch (Exception) { MessageBox.Show(this, "Error occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }