internal HRM_SUB_SECTIONS GetSubSectionById(string subSectionID, string OCODE) { int subSection = Convert.ToInt32(subSectionID); HRM_SUB_SECTIONS SubSction = _context.HRM_SUB_SECTIONS.First(x => x.SUB_SEC_ID == subSection); return(SubSction); }
internal int DleteSubSectionById(string subSectionID, string OCODE) { int subsctionId = Convert.ToInt16(subSectionID); HRM_SUB_SECTIONS subSection = _context.HRM_SUB_SECTIONS.First(i => i.SUB_SEC_ID == subsctionId); _context.HRM_SUB_SECTIONS.DeleteObject(subSection); _context.SaveChanges(); return(1); }
//-------Insert------------------------------------ public int InsertSub_Section(HRM_SUB_SECTIONS objS_Sec) { try { _context.HRM_SUB_SECTIONS.AddObject(objS_Sec); _context.SaveChanges(); return(1); } catch (Exception ex) { throw ex; } }
protected void imgbtnDepartmentEdit_Click(object sender, EventArgs e) { HRM_SUB_SECTIONS objSubSection = new HRM_SUB_SECTIONS(); ImageButton imgbtn = (ImageButton)sender; GridViewRow row = (GridViewRow)imgbtn.NamingContainer; try { string subSectionID = ""; Label lblSubSectionId = (Label)gridviewSubSection.Rows[row.RowIndex].FindControl("lblSubSection"); if (lblSubSectionId != null) { string OCODE = ((SessionUser)Session["SessionUser"]).OCode; subSectionID = lblSubSectionId.Text; objSubSection = objSubSec_BLL.GetSubSectionById(subSectionID, OCODE); //int result = objSubSec_BLL.DleteSubSectionById(OCODE, subSectionID); //if (result == 1) //{ // lblMessage.Text = "Data Delete successfully!"; // lblMessage.ForeColor = System.Drawing.Color.Red; // GetSubSections(); //} if (objSubSection != null) { hidSubSectionId.Value = objSubSection.SUB_SEC_ID.ToString(); txtbxSubSection.Text = objSubSection.SUB_SEC_NAME; GetResionForDepartment(); drpdwnResionForDepartment.SelectedValue = objSubSection.RegionID.ToString(); BridOfficeByResion(Convert.ToInt16(drpdwnResionForDepartment.SelectedValue)); drpdwnOffice.SelectedValue = objSubSection.OfficeID.ToString(); SetDepartmentByOfficeId(Convert.ToInt16(drpdwnOffice.SelectedValue)); drpDepartment.SelectedValue = objSubSection.DepartmentID.ToString(); SetSection(Convert.ToInt16(drpDepartment.SelectedValue)); drpSection.SelectedValue = objSubSection.SEC_ID.ToString(); //drpSection.SelectedValue = objSubSection.SEC_ID.ToString(); if (btnSave.Text == "Submit") { btnSave.Text = "Update"; } } } } catch (Exception ex) { throw; } }
//-------Delete------------------------------------ public int DeleteSub_Section(int subsectionID) { try { HRM_SUB_SECTIONS objSec = _context.HRM_SUB_SECTIONS.First(x => x.SUB_SEC_ID == subsectionID); _context.HRM_SUB_SECTIONS.DeleteObject(objSec); _context.SaveChanges(); return(1); } catch (Exception ex) { throw ex; } }
//-------Update------------------------------------ public int UpdateSub_Section(HRM_SUB_SECTIONS objS_Sec, int subsectionID) { try { HRM_SUB_SECTIONS obj = _context.HRM_SUB_SECTIONS.First(x => x.SUB_SEC_ID == subsectionID); obj.SUB_SEC_NAME = objS_Sec.SUB_SEC_NAME; obj.SEC_ID = objS_Sec.SEC_ID; obj.RegionID = objS_Sec.RegionID; obj.OfficeID = objS_Sec.OfficeID; obj.DepartmentID = objS_Sec.DepartmentID; obj.EDIT_USER = objS_Sec.EDIT_USER; obj.EDIT_DATE = objS_Sec.EDIT_DATE; obj.OCODE = objS_Sec.OCODE; _context.SaveChanges(); return(1); } catch (Exception ex) { throw ex; } }
protected void btnSave_Click(object sender, EventArgs e) { try { if (drpdwnResionForDepartment.SelectedItem.ToString() == "--Select--") { // lblMessage.Text = ""; // lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Region!')", true); } else if (drpdwnOffice.SelectedItem.ToString() == "--Select--") { // lblMessage.Text = ""; // lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Office!')", true); } else if (drpDepartment.SelectedItem.ToString() == "--Select--") { // lblMessage.Text = ""; // lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Department!')", true); } else if (drpSection.SelectedItem.ToString() == "--Select--") { // lblMessage.Text = ""; // lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Section!')", true); } else if (txtbxSubSection.Text == "") { // lblMessage.Text = ""; // lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input Sub-Section Name!')", true); } else { HRM_SUB_SECTIONS objSubsection = new HRM_SUB_SECTIONS(); objSubsection.SUB_SEC_NAME = txtbxSubSection.Text; objSubsection.SEC_ID = Convert.ToInt32(drpSection.SelectedValue.ToString()); objSubsection.RegionID = Convert.ToInt32(drpdwnResionForDepartment.SelectedValue.ToString()); objSubsection.OfficeID = Convert.ToInt32(drpdwnOffice.SelectedValue.ToString()); objSubsection.DepartmentID = Convert.ToInt32(drpDepartment.SelectedValue.ToString()); objSubsection.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId; objSubsection.EDIT_DATE = DateTime.Now; objSubsection.OCODE = ((SessionUser)Session["SessionUser"]).OCode; if (btnSave.Text == "Submit") { int result = objSubSec_BLL.InsertSub_Section(objSubsection); if (result == 1) { //lblMessage.Text = "Data Save successfully!"; // lblMessage.ForeColor = System.Drawing.Color.Green; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Save Successfully')", true); } } else { int sectionId = Convert.ToInt32(hidSubSectionId.Value); int result = objSubSec_BLL.UpdateSub_Section(objSubsection, sectionId); if (result == 1) { // lblMessage.Text = "Data Update successfully!"; // lblMessage.ForeColor = System.Drawing.Color.Green; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Update Successfully')", true); } } GetSubSections(); drpDepartment.ClearSelection(); drpSection.ClearSelection(); drpdwnOffice.ClearSelection(); drpdwnResionForDepartment.ClearSelection(); txtbxSubSection.Text = ""; btnSave.Text = "Submit"; } } catch (Exception) { throw; } }
//-------Update------------------------------------ public int UpdateSub_Section(HRM_SUB_SECTIONS objS_Sec, int subsectionID) { return(objCtx_DAL.UpdateSub_Section(objS_Sec, subsectionID)); }
//-------Insert------------------------------------ public int InsertSub_Section(HRM_SUB_SECTIONS objS_Sec) { return(objCtx_DAL.InsertSub_Section(objS_Sec)); }