Exemplo n.º 1
0
        internal HRM_DEPARTMENTS GetOfficeById(string deparId, string OCODE)
        {
            int             DepId = Convert.ToInt32(deparId);
            HRM_DEPARTMENTS dep   = _context.HRM_DEPARTMENTS.First(x => x.DPT_ID == DepId);

            return(dep);
        }
Exemplo n.º 2
0
 //-------Insert------------------------------------
 public int InsertDepartment(HRM_DEPARTMENTS objDept)
 {
     try
     {
         _context.HRM_DEPARTMENTS.AddObject(objDept);
         _context.SaveChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        protected void imgbtnDepartmentEdit_Click(object sender, EventArgs e)
        {
            HRM_DEPARTMENTS objectDepartment = new HRM_DEPARTMENTS();
            ImageButton     imgbtn           = (ImageButton)sender;
            GridViewRow     row = (GridViewRow)imgbtn.NamingContainer;

            try
            {
                string deparId         = "";
                Label  lblDepartmentId = (Label)gridviewDepartmetn.Rows[row.RowIndex].FindControl("lblDepartmetn");
                if (lblDepartmentId != null)
                {
                    string OCODE = ((SessionUser)Session["SessionUser"]).OCode;
                    deparId          = lblDepartmentId.Text;
                    objectDepartment = objDept_BLL.GetDepartmentByDepartmentId(deparId, OCODE);

                    if (objectDepartment != null)
                    {
                        hidDepartmentId.Value = objectDepartment.DPT_ID.ToString();
                        drpdwnResionForDepartment.SelectedValue = objectDepartment.ResionId.ToString();
                        int resionId = Convert.ToInt32(objectDepartment.ResionId.ToString());
                        BridOfficeByResion(resionId);
                        drpdwnOffice.SelectedValue = objectDepartment.Office_ID.ToString();
                        txtbxDepartemntName.Text   = objectDepartment.DPT_NAME.ToString();
                        int officeId = Convert.ToInt32(drpdwnOffice.SelectedValue);
                        SetOfficeCodeByofficeID(officeId);
                        string officeCode = objectDepartment.DPT_CODE.ToString();

                        bool contains = officeCode.Contains("-");

                        if (contains)
                        {
                            string[] occode = officeCode.Split('-');
                            txtbxDepartmentCode.Text = occode[1].ToString();
                        }
                        else
                        {
                            txtbxDepartmentCode.Text = officeCode;
                        }
                        if (btnDepartmentSubmit.Text == "Submit")
                        {
                            btnDepartmentSubmit.Text = "Update";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 4
0
 //-------Delete------------------------------------
 public int DeleteDepartment(int departmentID)
 {
     try
     {
         HRM_DEPARTMENTS objDept = _context.HRM_DEPARTMENTS.First(x => x.DPT_ID == departmentID);
         _context.HRM_DEPARTMENTS.DeleteObject(objDept);
         _context.SaveChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 5
0
 //-------Update------------------------------------
 public int UpdateDepartment(HRM_DEPARTMENTS objDept, int departmentID)
 {
     try
     {
         HRM_DEPARTMENTS obj = _context.HRM_DEPARTMENTS.First(x => x.DPT_ID == departmentID);
         obj.DPT_NAME  = objDept.DPT_NAME;
         obj.DPT_CODE  = objDept.DPT_CODE;
         obj.EDIT_USER = objDept.EDIT_USER;
         obj.EDIT_DATE = objDept.EDIT_DATE;
         obj.Office_ID = obj.Office_ID;
         obj.ResionId  = objDept.ResionId;
         _context.SaveChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 6
0
        protected void btnDepartmentSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (drpdwnResionForDepartment.SelectedItem.ToString() == "---Select One---")
                {
                    //   lblMessage.Text = "";
                    //   lblMessage.ForeColor = System.Drawing.Color.Red;
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Region!')", true);
                }


                else if (txtbxDepartemntName.Text == "")
                {
                    //   lblMessage.Text = "";
                    //    lblMessage.ForeColor = System.Drawing.Color.Red;
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input Department Name!')", true);
                }
                else if (txtbxDepartmentCode.Text == "")
                {
                    // lblMessage.Text = "P";
                    //  lblMessage.ForeColor = System.Drawing.Color.Red;
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('lease Input Department Code!')", true);
                }
                else if (txtbxDepartmentCode.Text.Length < 3)
                {
                    //  lblMessage.Text = "";
                    //  lblMessage.ForeColor = System.Drawing.Color.Red;
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Department Code Minmum Length 3!')", true);
                }
                else
                {
                    if (drpdwnOffice.SelectedItem.ToString() == "---Select One---")
                    {
                        //  lblMessage.Text = "";
                        //     lblMessage.ForeColor = System.Drawing.Color.Red;
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Office')", true);
                    }
                    else
                    {
                        HRM_DEPARTMENTS objDepartment = new HRM_DEPARTMENTS();
                        objDepartment.EDIT_USER = ((SessionUser)Session["SessionUser"]).UserId;
                        objDepartment.EDIT_DATE = DateTime.Now;
                        objDepartment.OCODE     = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode);
                        objDepartment.Office_ID = Convert.ToInt32(drpdwnOffice.SelectedValue.ToString());
                        objDepartment.DPT_NAME  = txtbxDepartemntName.Text;
                        objDepartment.ResionId  = Convert.ToInt32(drpdwnResionForDepartment.SelectedValue.ToString());
                        string offcode = lblOfficeCode.Text + txtbxDepartmentCode.Text;

                        objDepartment.DPT_CODE = offcode;

                        if (btnDepartmentSubmit.Text == "Submit")
                        {
                            if (IsExist(objDepartment.DPT_NAME, objDepartment.DPT_CODE))
                            {
                                int result = objDept_BLL.InsertDepartment(objDepartment);

                                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
                            {
                                // lblMessage.Text = "";
                                // lblMessage.ForeColor = System.Drawing.Color.Red;
                                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Already Exists!')", true);
                            }
                        }
                        else
                        {
                            int DepartmentId = Convert.ToInt32(hidDepartmentId.Value);

                            int result = objDept_BLL.UpdateDepartment(objDepartment, DepartmentId);

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

                        GetAllDepartmentforGridview();
                        ClearDepartmentUi();
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 7
0
 //-------Update------------------------------------
 public int UpdateDepartment(HRM_DEPARTMENTS objDept, int departmentID)
 {
     return objCtx_DAL.UpdateDepartment(objDept, departmentID);
 }
Exemplo n.º 8
0
 //-------Insert------------------------------------
 public int InsertDepartment(HRM_DEPARTMENTS objDept)
 {
     return objCtx_DAL.InsertDepartment(objDept);
 }