internal HRM_SECTIONS GetSctionBySectionId(string sectionId, string OCODE) { int Section = Convert.ToInt32(sectionId); HRM_SECTIONS dep = _context.HRM_SECTIONS.First(x => x.SEC_ID == Section); return(dep); }
protected void imgbtnDepartmentEdit_Click(object sender, EventArgs e) { HRM_SECTIONS objSection = new HRM_SECTIONS(); ImageButton imgbtn = (ImageButton)sender; GridViewRow row = (GridViewRow)imgbtn.NamingContainer; try { string sectionId = ""; Label lblSectionId = (Label)gridviewSection.Rows[row.RowIndex].FindControl("lblSection"); if (lblSectionId != null) { string OCODE = ((SessionUser)Session["SessionUser"]).OCode; string sId = lblSectionId.Text; //int result = objSec_BLL.DeleteSection(sId); //if (result == 1) //{ // lblMessage.Text = "Data Update successfully!"; // lblMessage.ForeColor = System.Drawing.Color.Red; // GetScections(); //} objSection = objSec_BLL.GetSctionBySectionId(sId, OCODE); if (objSection != null) { hidSectionId.Value = objSection.SEC_ID.ToString(); txtbxSection.Text = objSection.SEC_NAME; GetResionForDepartment(); drpdwnResionForDepartment.SelectedValue = objSection.RegionID.ToString(); BridOfficeByResion(Convert.ToInt16(drpdwnResionForDepartment.SelectedValue)); drpdwnOffice.SelectedValue = objSection.OfficeID.ToString(); GetDepartmentByOfficeID(Convert.ToInt16(drpdwnOffice.SelectedValue)); drpDepartment.SelectedValue = objSection.DPT_ID.ToString(); // drpDepartment.SelectedValue = objSection.DPT_ID.ToString(); if (btnSave.Text == "Submit") { btnSave.Text = "Update"; } } } } catch (Exception ex) { throw; } }
//-------Insert------------------------------------ public int InsertSection(HRM_SECTIONS objSec) { try { _context.HRM_SECTIONS.AddObject(objSec); _context.SaveChanges(); return(1); } catch (Exception ex) { throw ex; } }
//-------Delete------------------------------------ public int DeleteSection(int sectionID) { try { HRM_SECTIONS objSec = _context.HRM_SECTIONS.First(x => x.SEC_ID == sectionID); _context.HRM_SECTIONS.DeleteObject(objSec); _context.SaveChanges(); return(1); } catch (Exception ex) { throw ex; } }
//-------Update------------------------------------ public int UpdateSection(HRM_SECTIONS objSec, int sectionID) { try { HRM_SECTIONS obj = _context.HRM_SECTIONS.First(x => x.SEC_ID == sectionID); obj.SEC_NAME = objSec.SEC_NAME; obj.DPT_ID = objSec.DPT_ID; obj.RegionID = objSec.RegionID; obj.OfficeID = objSec.OfficeID; obj.EDIT_USER = objSec.EDIT_USER; obj.EDIT_DATE = objSec.EDIT_DATE; _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 Resion!')", 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 (txtbxSection.Text == "") { // lblMessage.Text = ""; // lblMessage.ForeColor = System.Drawing.Color.Red; ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input Section Name!')", true); } else { HRM_SECTIONS objsection = new HRM_SECTIONS(); objsection.DPT_ID = Convert.ToInt32(drpDepartment.SelectedValue.ToString()); objsection.OfficeID = Convert.ToInt32(drpdwnOffice.SelectedValue.ToString()); objsection.RegionID = Convert.ToInt32(drpdwnResionForDepartment.SelectedValue.ToString()); objsection.DPT_ID = Convert.ToInt32(drpDepartment.SelectedValue.ToString()); objsection.SEC_NAME = txtbxSection.Text; objsection.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId; objsection.EDIT_DATE = DateTime.Now; objsection.OCODE = ((SessionUser)Session["SessionUser"]).OCode; if (btnSave.Text == "Submit") { int result = objSec_BLL.SaveSection(objsection); 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(hidSectionId.Value); int result = objSec_BLL.UpdateOffice(objsection, 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); } } //DepartmentList(); GetScections(); drpDepartment.ClearSelection(); drpdwnOffice.ClearSelection(); drpdwnResionForDepartment.ClearSelection(); txtbxSection.Text = ""; btnSave.Text = "Submit"; } } catch (Exception) { throw; } }
internal int UpdateOffice(HRM_SECTIONS objsection, int sectionId) { return(objCtx_DAL.UpdateSection(objsection, sectionId)); }
internal int SaveSection(HRM_SECTIONS objsection) { return(objCtx_DAL.InsertSection(objsection)); }
//-------Update------------------------------------ public int UpdateSection(HRM_SECTIONS objSec, int sectionID) { return(objCtx_DAL.UpdateSection(objSec, sectionID)); }
//-------Insert------------------------------------ public int InsertSection(HRM_SECTIONS objSec) { return(objCtx_DAL.InsertSection(objSec)); }