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); } }
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); } }