protected void RadGrid1_OnItemCommand(object sender, GridCommandEventArgs e)
 {
     try
     {
         GridDataItem item = (GridDataItem)e.Item;
         string id = item["colId"].Text;
         switch (e.CommandName)
         {
             case "btnSelect":
                 {
                    Response.Redirect("DesignationInformation.aspx?id="+id,true);
                     break;
                 }
             case "btnDelete":
                 int del = new Designation().DeleteDesignationByDesignationId(int.Parse(id));
                 if (del == 0)
                     Alert.Show("Data is not deleted");
                 else
                 {
                     this.LoadDesignationTable();
                 }
                 break;
         }
     }
     catch (Exception ex)
     {
         Alert.Show(ex.Message);
     }
 }
Ejemplo n.º 2
0
        public void LoadDesignationDropDownList()
        {
            Designation newDeg = new Designation();

            List<Designation> newDegList = newDeg.GetAllDesignation(_company.CompanyId);
            designationDropDownList.DataSource = newDegList;
            designationDropDownList.DataTextField = "Designation";
            designationDropDownList.DataValueField = "DesignationId";
            designationDropDownList.DataBind();
        }
        private void LoadDesignationTable()
        {
            try
            {
                Designation objDesignation =new Designation();
                List<Designation> objDesignationList = objDesignation.GetAllDesignation(_company.CompanyId);
                foreach (Designation aDesignation in objDesignationList)
                {
                    if (aDesignation.DepartmentId != 0)
                    {
                        Department aDepartment = new Department().GetDepartmentByDepartmentId(
                            aDesignation.DepartmentId, _company.CompanyId);
                        aDesignation.DepartmentName = aDepartment.DepartmentName;
                    }
                    else
                    {
                        aDesignation.DepartmentName = "None";
                    }
                }
                RadGrid1.DataSource = objDesignationList;
                RadGrid1.Rebind();

            }
            catch (Exception ex)
            {
                Alert.Show(ex.Message);
            }
        }
        private void LoadEmployeeListTable()
        {
            try
            {
                Addresses tempAddres = new Addresses();
                Designation tempDesignation = new Designation();
                Department tempDepartment = new Department();
                Employee objEmployee = new Employee();
                List<Employee> objEmployeeList = objEmployee.GetAllEmployee(_company.CompanyId);
                foreach (Employee employee in objEmployeeList)
                {

                    List<Addresses> objAddressList = tempAddres.GetAllAddresses(_company.CompanyId);
                    Designation aDesignation = tempDesignation.GetDesignationByDesignationId(employee.DesignationId,_company.CompanyId);
                    Department aDepartment = tempDepartment.GetDepartmentByDepartmentId(employee.DepartmentId,
                        _company.CompanyId);
                    employee.DepartmentName = aDepartment.DepartmentName;
                    employee.DesignationName = aDesignation.Designation;
                    employee.DOB = DateTime.Parse(employee.DOB).ToShortDateString();
                    employee.JoinDate = DateTime.Parse(employee.JoinDate).ToShortDateString();
                    List<string> countrList = Country.CountryList();

                    foreach (Addresses anAddresses in objAddressList)
                    {
                        if (anAddresses.SourceType == "Employee" && anAddresses.SourceId == employee.EmployeeId)
                        {
                            employee.AddressLine1 = anAddresses.AddressLine1;
                            employee.AddressLine2 = anAddresses.AddressLine2;
                            employee.City = anAddresses.City;
                            employee.ZipCode = anAddresses.ZipCode;
                            employee.Phone = anAddresses.Phone;
                            employee.Mobile = anAddresses.Mobile;
                            employee.Email = anAddresses.Email;
                            employee.CountryName = countrList[anAddresses.CountryId];
                            break;

                        }

                    }
                    RadGrid1.DataSource = objEmployeeList;
                    RadGrid1.Rebind();

                }
            }
            catch (Exception ex)
            {
                Alert.Show(ex.Message);
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Designation newDesignation = new Designation();

                bool chk = false;
                Employee aEmployee = new Employee();
                Addresses aAddresses=new Addresses();
                List<Employee> employeeListC =aEmployee.GetAllEmployee(_company.CompanyId);
                if (lblId.Text == "" || lblId.Text == "0")
                foreach (Employee anEmployee in employeeListC)
                {
                    if (anEmployee.EmployeeCode == txtEmployeeCode.Value)
                    {
                        Session["empMessage"] = "Employee Code is exist! Try Again";
                        chk = true;
                        break;
                    }
                }
                 if (chk == true)
                {
                    Response.Redirect(Request.RawUrl);
                }
                Employee tempEmployee = new Employee();

                aEmployee.EmployeeCode = txtEmployeeCode.Value;
                aEmployee.EmployeeName = txtEmployeeName.Value;
                aEmployee.DOB = RadDatePicker1.SelectedDate.ToString();
                aEmployee.JoinDate = JoinRadDatePicker.SelectedDate.ToString();

                aEmployee.DepartmentId = int.Parse(departmentDropDownList.SelectedIndex>-1?departmentDropDownList.SelectedItem.Value:"0");
                aEmployee.DesignationId = int.Parse(designationDropDownList.SelectedItem.Value);
                aEmployee.Address = "Main Address";
                aAddresses.SourceType = "Employee";
                aAddresses.AddressLine1 = txtAddressLine1.Value;
                aAddresses.AddressLine2 = txtAddressLine2.Value;
                aAddresses.AddressType = "Main Address";
                aAddresses.CountryId = int.Parse(countryDropDownList.SelectedIndex.ToString());
                aAddresses.City = txtCity.Value;
                aAddresses.ZipCode = txtZipCode.Value;
                aAddresses.Email = txtEmail.Value;
                aAddresses.Web = "";
                aAddresses.Phone = txtPhoneNo.Value;
                aAddresses.Mobile = txtMobile.Value;
                aAddresses.CompanyId = _company.CompanyId;
                aEmployee.CompanyId = _company.CompanyId;
                aEmployee.IsActive = true;
                aEmployee.UpdateBy = user.UserId;
                aEmployee.UpdateDate = DateTime.Now;
                if (lblId.Text == "" || lblId.Text == "0")
                {
                    aEmployee.EmployeeId = new Employee().GetMaxEmployeeId() + 1;
                    aAddresses.SourceId = aEmployee.EmployeeId;
                    aAddresses.AddressId = new Addresses().GetMaxAddressId() + 1;

                    int chkEmployee = aEmployee.InsertEmployee();
                    int chkAddress = aAddresses.InsertAddresses();
                    if (chkAddress > 0 && chkEmployee > 0)
                    {
                        Session["empMessage"] = "Saved Successfully";
                        Response.Redirect(Request.RawUrl);

                    }
                    else
                    {
                        Alert.Show("Error occured while inserting employee information");
                    }
                }
                else
                {
                    aEmployee.EmployeeId = int.Parse(lblId.Text);
                    aAddresses.SourceId = aEmployee.EmployeeId;
                    aAddresses.AddressId = long.Parse(addlblId.Text);
                   int chk3= aEmployee.UpdateEmployee();
                    int chk1=aAddresses.UpdateAddresses();
                    if(chk3>0&&chk1>0)
                        Response.Redirect("EmployeeList.aspx",true);

                }

            }
            catch (Exception exp)
            {
                Alert.Show(exp.Message);
            }
        }
 private void LoadDesignationDropDownList(int id)
 {
     designationDropDownList.ClearSelection();
     int departmentId = id ;
     List<Designation> oDesignationList = new Designation().GetDesignationbyDepartmentId(departmentId);
     designationDropDownList.DataSource = oDesignationList;
     designationDropDownList.DataTextField = "Designation";
     designationDropDownList.DataValueField = "DesignationId";
     designationDropDownList.DataBind();
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            _company = (Company)Session["Company"];
            user = (Users)Session["user"];

            this.LoadCountryDropDownList();
            this.LoadDepartmentDropDownList();

            if (!isValidSession())
            {
                string str = Request.QueryString.ToString();
                if (str == string.Empty)
                {
                    Response.Redirect("LogIn.aspx?refPage=index.aspx");
                }
                else
                {
                    Response.Redirect("LogIn.aspx?regPage=index.aspx"+str);
                }
            }
            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    string id = Request.QueryString["id"].ToString();
                    Employee tempEmployee= new Employee().GetEmployeeByEmployeeId(int.Parse(id),_company.CompanyId);
                    if (tempEmployee != null || tempEmployee.EmployeeId != 0)
                    {
                        List<string> countryList = Country.CountryList();
                        List<Addresses> addressList = new Addresses().GetAllAddresses(_company.CompanyId);
                        Designation designation =
                            new Designation().GetDesignationByDesignationId(tempEmployee.DesignationId,
                                _company.CompanyId);
                        Department department;
                        if (tempEmployee.DepartmentId != 0)
                        {
                            department = new Department().GetDepartmentByDepartmentId(tempEmployee.DepartmentId,
                                _company.CompanyId);
                            SetIndex(departmentDropDownList, department.DepartmentId.ToString());
                            LoadDesignationDropDownList(tempEmployee.DepartmentId);

                        }
                        else
                        {
                            department = new Department();
                            departmentDropDownList.SelectedIndex = -1;
                            LoadDesignationDropDownList(0);
                        }
                        SetIndex(designationDropDownList,tempEmployee.DesignationId.ToString());
                        lblId.Text = tempEmployee.EmployeeId.ToString();
                        txtEmployeeCode.Value = tempEmployee.EmployeeCode;
                        txtEmployeeName.Value = tempEmployee.EmployeeName;
                        JoinRadDatePicker.SelectedDate = DateTime.Parse(tempEmployee.JoinDate);
                        RadDatePicker1.SelectedDate = DateTime.Parse(tempEmployee.DOB);
                        chkIsActive.Checked = tempEmployee.IsActive;

                       //SetIndex(designationDropDownList,designation.DesignationId.ToString());
                        foreach (Addresses tAddress in addressList)
                        {
                            if (tAddress.SourceType == "Employee" && tAddress.SourceId == tempEmployee.EmployeeId)
                            {
                                addlblId.Text = tAddress.AddressId.ToString();
                                txtAddressLine1.Value = tAddress.AddressLine1;
                                txtAddressLine2.Value = tAddress.AddressLine2;
                                txtCity.Value = tAddress.City;
                                txtEmail.Value = tAddress.Email;
                                txtZipCode.Value = tAddress.ZipCode;
                                txtPhoneNo.Value = tAddress.Phone;
                                countryDropDownList.SelectedIndex = tAddress.CountryId;
                                break;

                            }

                        }
                    }

                }
            }
            if (Session["empMessage"] != null)
            {
                string message = Session["empMessage"].ToString();
                Session["empMessage"] = null;
                Alert.Show(message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                _company = (Company) Session["Company"];
                if (!isValidSession())
                {
                    string str = Request.QueryString.ToString();
                    if (str == string.Empty)
                        Response.Redirect("LogIn.aspx?refPage=index.aspx");
                    else
                        Response.Redirect("LogIn.aspx?refPage=index.aspx?" + str);
                }

                this.LoadDesignationTable();
                this.LoadDepartmentDropDownList();
                if (!IsPostBack)
                {
                    if (Request.QueryString["id"] != null)
                    {
                        string designationID = Request.QueryString["id"].ToString();
                        Designation objDesignation =
                            new Designation().GetDesignationByDesignationId(int.Parse(designationID), _company.CompanyId);
                        lblId.Text = objDesignation.DesignationId.ToString();
                        if (objDesignation != null || objDesignation.DepartmentId != 0)
                        {
                            Department aDepartment =
                                new Department().GetDepartmentByDepartmentId(objDesignation.DesignationId,
                                    _company.CompanyId);

                            txtDesignationName.Value = objDesignation.Designation;
                            SetIndex(departmentIdRadDropDownList, objDesignation.DepartmentId.ToString());
                            chkIsActive.Checked = objDesignation.IsActive;
                        }

                    }
                }
                if (Session["designationInfoMsg"] != null)
                {
                    string str = Session["designationInfoMsg"].ToString();
                    Alert.Show(str);
                    Session["designationInfoMsg"] = null;
                }
            }
            catch (Exception ex)
            {
                Alert.Show(ex.Message);
            }
        }
        private void SaveDesignation()
        {
            try
            {
                Designation aDesignation = new Designation();
                aDesignation.Designation = txtDesignationName.Value;
                aDesignation.CompanyId = _company.CompanyId;
                aDesignation.DepartmentId = departmentIdRadDropDownList.SelectedIndex > -1 ? int.Parse(departmentIdRadDropDownList.SelectedItem.Value) : int.Parse("0");
                aDesignation.UpdateDate = DateTime.Now;
                aDesignation.UpdateBy = user.UserId;

               // aDesignation.UpdateBy = user.User;
                aDesignation.IsActive = chkIsActive.Checked;
                if (lblId.Text == "" || lblId.Text == "0")
                {
                    aDesignation.DesignationId = new Designation().GetMaxdesignationID() + 1;
                    int success = aDesignation.InsertDesignation();
                    string msg=(success > 0 ? "Designation Saved Successfully" : "Something Error Happened");
                    Session["designationInfoMsg"] = msg;
                    this.Clear();
                    Response.Redirect(Request.RawUrl);

                }
                else
                {
                    aDesignation.DesignationId = int.Parse(lblId.Text);
                    int check = aDesignation.UpdateDesignation();
                    if (check > 0)
                    {
                        Response.Redirect("DesignationList.aspx", true);

                    }
                    else
                    {
                        Alert.Show("Updated is not successfully done");
                    }
                }

            }
            catch (Exception exception)
            {
                Alert.Show(exception.Message);
            }
        }
 private void LoadDesignationTable()
 {
     Designation newDesignation = new Designation();
     objDesignationList = newDesignation.GetAllDesignation(_company.CompanyId);
     //RadGrid1.DataSource = objDesignationList;
     //RadGrid1.Rebind();
 }
        private void SaveDesignation()
        {
            try
            {
                Designation aDesignation = new Designation();
                aDesignation.Designation = txtDesignation.Value;
                aDesignation.CompanyId = int.Parse(companyIdRadDropDownList1.SelectedItem.Value);
                aDesignation.DepartmentId = int.Parse(departmentIdRadDropDownList.SelectedItem.Value);
                aDesignation.UpdateDate = DateTime.Now;
                //aDesignation.UpdateBy = user.UserId;
                aDesignation.UpdateBy = 1;
                aDesignation.IsActive = chkIsActive.Checked;
               int success= aDesignation.InsertDesignation();
                Alert.Show(success>0?"Designation Saved Successfully":"Something Error Happened");

            }
            catch (Exception exception)
            {
                Alert.Show(exception.Message);
            }
        }