Click here to Skip to main content
15,903,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a question, can anyone help please?

In my project I have one personal information page, if any new employee joins then HR will fill in that page because that person will have the access. Now we are thinking of giving access to the employee so that they can fill in their own information and save it in the database.
But the problem is that HR are telling me that after that employee fills in the page and if they want to do any changes, the edit button should not be visible for them. They should only be able to access it the first time.

Any suggestions please?

this is the code where i need to keep the required condition.
C#
#region HRMSEmpPersonal
public partial class HRMSEmpPersonal : System.Web.UI.Page
{
    #region GlobalDeclarion
    string qstring;
    int index;
    ArrayList empName = null;
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    #endregion

    #region Pageload
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            qstring = Request.QueryString["EmployeeID"];
            if (!IsPostBack)
            {
                if (((string)Session["roleId"] == "1") || ((string)Session["roleId"] == "2"))
                {
                    //tblUsercntrl.Visible = true;
                    tblbuttons.Visible = true;
                    rbnMNo.Visible = true;
                    rbnMYes.Visible = true;
                    lblGreeting.Visible = true;
                    rbnNo.Visible = true;
                    rbnYes.Visible = true;
                    lblMGreetings.Visible = true;
                    //Search();
                }
                else
                {
                    //tblUsercntrl.Visible = false;
                    tblbuttons.Visible = false;
                    rbnMNo.Visible = false;
                    rbnMYes.Visible = false;
                    lblGreeting.Visible = false;
                    rbnNo.Visible = false;
                    rbnYes.Visible = false;
                    lblMGreetings.Visible = false;
                }
                Country();
                ResidenceStatus();
                JobTitle();
                EmployeeType();
                MaritalStatus();
                if (qstring == null)
                {
                    //hdnTest.Value = Session["EmployeeID"].ToString();
                    if (Session["ViewEmpid"] != null)
                    {
                        hdnTest.Value = (string)Session["ViewEmpid"];
                        lblheader.Text = "Personal Information : " + (string)Session["ViewEmployeeName"];
                    }
                    else
                    {
                        hdnTest.Value = (string)Session["EmployeeID"];
                        //  lblheader.Text = "Personal Information : " + (string)Session["EmployeeName"];
                    }
                    RetrieveEmpInfo();
                }
                else  if (qstring != "New")
                {
                    LoginBL loginBL = new LoginBL();
                    LoginBM loginBM = new LoginBM();
                    hdnTest.Value = qstring;
                    Session["ViewEmpid"] = qstring;
                    empName = loginBL.GetEmployeeName(qstring);
                    Session["ViewEmployeeName"] = empName[0];
                    lblheader.Text = "Personal Information : " + (string)Session["ViewEmployeeName"];
                    RetrieveEmpInfo();
                }
                //else
                //{
                //    tblUsercntrl.Visible = false;
                //}
            }
            ddlResidenceStatus.Attributes.Add("onchange", "StatusChange()");
            ddlMaritalStatus.Attributes.Add("onchange", "MaritalStatus()");
            if (qstring == "New")
            {
                ddlJobTitle.Visible = true;
                ddlMaritalStatus.Visible = true;
                ddlNationality.Visible = true;
                ddlResidenceStatus.Visible = true;
                ddlEmpType.Visible = true;
                txtJobTitle.Visible = false;
                txtMStatus.Visible = false;
                txtEmpType.Visible = false;
                txtNationality.Visible = false;
                txtRStatus.Visible = false;
                btnEdit.Visible = false;
                rbnMNo.Visible = true;
                rbnMYes.Visible = true;
                lblGreeting.Visible = true;
                rbnNo.Visible = true;
                rbnYes.Visible = true;
                lblMGreetings.Visible = true;
               // ClearControls();
            }
            //GVEmpInfo.Visible = true;
            //txtSearch.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearch.UniqueID + "').click();return false;}} else {return true}; ");

        }
        catch (Exception ex)
        {
            if (log.IsErrorEnabled)
            {
                log.Error(ex.Message);
            }
        }
    }
    #endregion

    #region Events
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        try
        {

            hdnEdit.Value = "1";
            foreach (Control c in pnlPersonal.Controls)
            {
                if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
                {
                    TextBox t = (TextBox)c;
                    if (t.ID == "txtEmployeId")
                    {
                    }
                    else
                    {
                        t.ReadOnly = false;
                        t.BackColor = System.Drawing.Color.White;
                        t.BorderStyle = BorderStyle.NotSet;
                    }
                }
            }
            foreach (Control c in tblPersonal.Controls)
            {
                if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
                {
                    TextBox t = (TextBox)c;
                    t.ReadOnly = false;
                    t.BackColor = System.Drawing.Color.White;
                    t.BorderStyle = BorderStyle.NotSet;
                }
            }

            ControlVisibility();
            txtpswrd.Visible = false;
            txtRetypePswrd.Visible = false;
            lblPswrd.Visible = false;
            lblRetype.Visible = false;
            lblRetypemand.Visible = false;
            lblPswrdmand.Visible = false;
            string[] ImgUrls = imgEmployee.ImageUrl.Split('=');
            Session["PrevImg"] = ImgUrls[1];
        }
        catch (Exception ex)
        {
            if (log.IsErrorEnabled)
            {
                log.Error(ex.Message);
            }
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            //imgFileUpload.FileContent.Dispose();
            string fname;
            string path="";


            EmpBM empBM = new EmpBM();
            EmpBL empBL = new EmpBL();

            hdnTest.Value = txtEmployeId.Text.Trim();
            empBM.EmpId = hdnTest.Value;

            empBM.EmpFName = txtFirstName.Text;
            empBM.EmpMName = txtMiddleName.Text;
            empBM.EmpLName = txtLastName.Text;
            if (ddlJobTitle.SelectedIndex > 0)
                empBM.JobTitleId = Convert.ToInt32(ddlJobTitle.SelectedValue);
            if (txtSSN.Text.Contains('*'))
            {
                empBM.PANno = ViewState["pan"].ToString();
            }
            else
            {
                empBM.PANno = txtSSN.Text;
            }
            empBM.Nationality = Convert.ToInt32(ddlNationality.SelectedValue);
            if (txtJoiningDate.Text != string.Empty)
            {
                empBM.DOJ = Convert.ToDateTime(txtJoiningDate.Text);
            }
            else
            {
                empBM.DOJ = Convert.ToDateTime("01/01/1753");
            }
            if (txtTerminationDate.Text != string.Empty)
            {
                empBM.DOT = Convert.ToDateTime(txtTerminationDate.Text);

            }
            else
            {
                empBM.DOT = Convert.ToDateTime("01/01/1753");
            }
            if (txtPayrollDate.Text != string.Empty)
            {
                empBM.Payrolldate = Convert.ToDateTime(txtPayrollDate.Text);

            }
            else
            {
                empBM.Payrolldate = Convert.ToDateTime("01/01/1753");
            }
            empBM.Reason = txtTerminationReason.Text;
            if (txtBirthDate.Text != string.Empty)
            {
                empBM.DOB = Convert.ToDateTime(txtBirthDate.Text);
            }
            else
            {
                empBM.DOB = Convert.ToDateTime("01/01/1753");
            }
            empBM.DLnumber = txtLicenseNo.Text;
            if (txtExpiryDate.Text != string.Empty)
            {
                empBM.ExpiryDate = Convert.ToDateTime(txtExpiryDate.Text);
            }
            else
            {
                empBM.ExpiryDate = Convert.ToDateTime("01/01/1753");
            }
            if (rbnYes.Checked == true)
            {
                empBM.BGreeting = true;
            }
            else if (rbnNo.Checked == true)
            {
                empBM.BGreeting = false;
            }
            if (ddlMaritalStatus.SelectedIndex != 0)
            {
                empBM.MStatus = Convert.ToInt32(ddlMaritalStatus.SelectedValue);
            }

            if (rbnMYes.Checked == true)
            {
                empBM.MGreeting = true;
            }

            else if (rbnMNo.Checked == true)
            {
                empBM.MGreeting = false;
            }
            empBM.RStatus = Convert.ToInt32(ddlResidenceStatus.SelectedValue);

            if (rbnMale.Checked == true)
            {
                empBM.Gender = true;
            }
            else if (rbnFemale.Checked == true)
            {
                empBM.Gender = false;
            }
            if (ddlEmpType.SelectedIndex != 0)
            {
                empBM.EmployeeTypeId = Convert.ToInt32(ddlEmpType.SelectedValue);
            }
            if (txtMarriage.Text != string.Empty)
            {
                empBM.MarriageDay = Convert.ToDateTime(txtMarriage.Text);
            }
            else
            {
                empBM.MarriageDay = Convert.ToDateTime("01/01/1753");
            }

            if (imgFileUpload.PostedFile != null && imgFileUpload.PostedFile.FileName != "")
            {
                string fileExtension = System.IO.Path.GetExtension(imgFileUpload.FileName).ToLower();
                if (fileExtension == ".png" || fileExtension == ".jpg" || fileExtension == ".gif" || fileExtension == ".bmp" || fileExtension == ".jpeg")
                {

                    fname = imgFileUpload.PostedFile.FileName;
                    string uploadpath = "C:\\Pictures";
                    if (Directory.Exists(uploadpath))
                    {
                        if (Session["PrevImg"] != null)
                        {
                            if (Session["PrevImg"].ToString().Contains("Current"))
                            {
                                path = uploadpath + "\\" + txtEmployeId.Text.Trim() + "Latest" + fileExtension;
                            }
                            else if (Session["PrevImg"].ToString().Contains("Latest"))
                            {
                                path = uploadpath + "\\" + txtEmployeId.Text.Trim() + "Current" + fileExtension;
                            }
                            else
                            {
                                path = uploadpath + "\\" + txtEmployeId.Text.Trim() + "Current" + fileExtension;
                            }
                        }
                        else
                        {
                            path = uploadpath + "\\" + txtEmployeId.Text.Trim() + "Current" + fileExtension;
                        }
                        imgFileUpload.PostedFile.SaveAs(path);
                    }
                    else
                    {
                        Directory.CreateDirectory(uploadpath);
                        path = uploadpath + "\\" + txtEmployeId.Text.Trim() + "Current" + fileExtension;
                        imgFileUpload.PostedFile.SaveAs(uploadpath + "\\" + txtEmployeId.Text.Trim() + fileExtension);
                        imgFileUpload.FileContent.Dispose();

                    }
                    empBM.EmpImage = path.ToString();
                    Stream fs = new FileStream(empBM.EmpImage, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    int fileSize = Convert.ToInt32(fs.Length);
                    byte[] imageBinary = new byte[fileSize];
                    fs.Read(imageBinary, 0, fileSize);
                    fs.Close();
                   imgEmployee.ImageUrl = empBM.EmpImage;

                }
                else
                {
                    if (hdnEdit.Value == string.Empty)
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "<script language='javascript'>alert('Please Upload valid File')</script>");
                    }

                }
            }
            else
            {
                empBM.EmpImage = hdnFileupload.Value;
            }
            empBM.Password = txtpswrd.Text;
            empBM.EmailID = txtEmail.Text;
            if (hdnEdit.Value == string.Empty)
            {
                empBL.AddEmployeeInformation(empBM);

                SendMail();
            }
            else
            {
                //if (txtTerminationDate.Text != string.Empty)
                //{
                //    empBM.Flag = 4;
                //}
                //else
                //{
                //    empBM.Flag = 0;
                //}
                empBL.UpdateEmployeeInformation(empBM);
            }
            RetrieveEmpInfo();
            if (imgFileUpload.PostedFile != null && imgFileUpload.PostedFile.FileName != "")
            {
                if (File.Exists(Session["PrevImg"].ToString()))
                {
                    File.Delete(Session["PrevImg"].ToString());
                }
            }
            hdnEdit.Value = string.Empty;
        }
        catch (Exception ex)
        {
            if (log.IsErrorEnabled)
            {
                log.Error(ex.Message);
            }

        }
    }

    protected void btnCancel_Click1(object sender, EventArgs e)
    {
        RetrieveEmpInfo();
    }

    //protected void GVEmpInfo_PageIndexChanging(object sender, GridViewPageEventArgs e)
    //{
    //    try
    //    {
    //        GVEmpInfo.PageIndex = e.NewPageIndex;
    //        FillGridbySearch();
    //    }
    //    catch (Exception ex)
    //    {
    //        if (log.IsErrorEnabled)
    //        {
    //            log.Error(ex.Message);
    //        }
    //    }
    //}
    #endregion

    #region Methods
    public void RetrieveEmpInfo()
    {
        try
        {
            ClearControls();
            EmpBM empBM = new EmpBM();
            EmpBL empBL = new EmpBL();
            empBM = empBL.GetEmployeeData(hdnTest.Value);
            if (empBM != null)
            {
                foreach (Control c in pnlPersonal.Controls)
                {
                    if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
                    {
                        TextBox t = (TextBox)c;
                        t.ReadOnly = true;
                        t.BackColor = System.Drawing.Color.WhiteSmoke;
                        t.BorderStyle = BorderStyle.None;
                    }
                }
                foreach (Control c in tblPersonal.Controls)
                {
                    if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
                    {
                        TextBox t = (TextBox)c;
                        t.ReadOnly = true;
                        t.BackColor = System.Drawing.Color.WhiteSmoke;
                        t.BorderStyle = BorderStyle.None;
                    }
                }


                if (null != empBM.EmpFName)
                {
                    txtFirstName.Text = empBM.EmpFName;
                }
                if (null != empBM.EmpMName)
                {
                    txtMiddleName.Text = empBM.EmpMName;
                }
                if (null != empBM.EmpLName)
                {
                    txtLastName.Text = empBM.EmpLName;
                }
                if (null != empBM.EmpId)
                {
                    txtEmployeId.Text = empBM.EmpId;
                }
                if (string.Empty != empBM.PANno)
                {

                    ViewState["pan"] = empBM.PANno;
                    string pan = empBM.PANno;
                    int length = pan.Length;
                    string ssn = string.Empty;
                    ssn = pan.Substring(0, length - 4);
                    for (int i = 0; i < ssn.Length; i++)
                    {
                        ssn = ssn.Replace(ssn[i].ToString(), "*");

                    }
                    txtSSN.Text = ssn + pan.Substring(length - 4);

                }
                if (empBM.Nationality != 0)
                {
                    ddlNationality.SelectedValue = empBM.Nationality.ToString();
                    txtNationality.Text = ddlNationality.SelectedItem.Text;
                }
                if (empBM.EmployeeTypeId != 0)
                {
                    ddlEmpType.SelectedValue = empBM.EmployeeTypeId.ToString();
                    txtEmpType.Text = ddlEmpType.SelectedItem.Text;
                }
                string DOJ = empBM.DOJ.ToString("MM/dd/yyyy");
                if (DOJ.Equals("01/01/1753"))
                {
                    txtJoiningDate.Text = string.Empty;
                }
                else
                {
                    txtJoiningDate.Text = empBM.DOJ.ToString("MM/dd/yyyy");
                }

                string DOT = empBM.DOT.ToString("MM/dd/yyyy");
                if (DOT.Equals("01/01/1753") || DOT.Equals("01/01/0001"))
                {
                    txtTerminationDate.Text = string.Empty;
                }
                else
                {
                    txtTerminationDate.Text = empBM.DOT.ToString("MM/dd/yyyy");
                }
                string PayrollDate = empBM.Payrolldate.ToString("MM/dd/yyyy");
                if (PayrollDate.Equals("01/01/1753")||PayrollDate.Equals(null)||PayrollDate.Equals("01/01/0001"))
                {
                    txtPayrollDate.Text = string.Empty;
                }
                else
                {
                    txtPayrollDate.Text = empBM.Payrolldate.ToString("MM/dd/yyyy");
                }
                if (empBM.Reason != null)
                {
                    txtTerminationReason.Text = empBM.Reason;
                }
                string DOB = empBM.DOB.ToString("MM/dd/yyyy");
                if (DOB.Equals("01/01/1753"))
                {
                    txtBirthDate.Text = string.Empty;
                }
                else
                {
                    txtBirthDate.Text = empBM.DOB.ToString("MM/dd/yyyy");
                }
                if (empBM.JobTitleId != 0)
                {
                    ddlJobTitle.SelectedValue = empBM.JobTitleId.ToString();
                    txtJobTitle.Text = ddlJobTitle.SelectedItem.Text;
                }
                if (empBM.BGreeting == true)
                {
                    rbnYes.Checked = true;
                }
                else
                {
                    rbnNo.Checked = true;
                }
                if (empBM.MStatus != 0)
                {
                    ddlMaritalStatus.SelectedValue = empBM.MStatus.ToString();
                    txtMStatus.Text = ddlMaritalStatus.SelectedItem.Text;
                }
                if (empBM.MGreeting == true)
                {
                    rbnMYes.Checked = true;
                }
                else
                {
                    rbnMNo.Checked = true;
                }
                if (empBM.Gender == true)
                {
                    rbnMale.Checked = true;
                }
                else
                {
                    rbnFemale.Checked = true;
                }
                if (empBM.DLnumber != null)
                {
                    txtLicenseNo.Text = empBM.DLnumber;
                }

                string expDate = empBM.ExpiryDate.ToString("MM/dd/yyyy");

                if (expDate.Equals("01/01/1753") || expDate.Equals("01/01/0001"))
                {
                    txtExpiryDate.Text = string.Empty;
                }
                else
                {
                    txtExpiryDate.Text = empBM.ExpiryDate.ToString("MM/dd/yyyy");
                }
                if (empBM.EmailID != null)
                {
                    txtEmail.Text = empBM.EmailID;
                }
                if (empBM.RStatus != 0)
                {
                    ddlResidenceStatus.SelectedValue = empBM.RStatus.ToString();
                    txtRStatus.Text = ddlResidenceStatus.SelectedItem.Text;

                }
                if (empBM.EmpImage != null)
                {

                    imgEmployee.ImageUrl = "HRMSImagedisp.aspx?id=" + empBM.EmpImage;

                }
                hdnFileupload.Value = empBM.EmpImage;
                imgFileUpload.Visible = false;
                tblPersonal.Visible = true;
                imgExpiryDateCalender.Visible = false;
                imgTerminationDateCalender.Visible = false;
                imgJoiningDateCalendar.Visible = false;
                imgPayrollDate.Visible = false;
                imgBirthDate.Visible = false;
                ddlJobTitle.Visible = false;
                ddlMaritalStatus.Visible = false;
                ddlNationality.Visible = false;
                ddlResidenceStatus.Visible = false;
                ddlEmpType.Visible = false;
                txtJobTitle.Visible = true;
                txtMStatus.Visible = true;
                txtNationality.Visible = true;
                txtEmpType.Visible = true;
                txtRStatus.Visible = true;
                btnEdit.Visible = true;
                btnSave.Visible = false;
                btnCancel.Visible = false;
                rbnFemale.Enabled = false;
                rbnMale.Enabled = false;
                rbnMNo.Enabled = false;
                rbnMYes.Enabled = false;
                rbnNo.Enabled = false;
                rbnYes.Enabled = false;
                txtpswrd.Visible = false;
                txtRetypePswrd.Visible = false;
                lblPswrd.Visible = false;
                lblRetype.Visible = false;
                lblRetypemand.Visible = false;
                lblPswrdmand.Visible = false;
                //btnAddDesg.Visible = false;
                foreach (Control c in pnlPersonal.Controls)
                {
                    if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
                    {

                        TextBox t = (TextBox)c;

                        t.ReadOnly = true;
                        t.BackColor = System.Drawing.Color.WhiteSmoke;
                        t.BorderStyle = BorderStyle.None;
                    }
                }
                foreach (Control c in tblPersonal.Controls)
                {
                    if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
                    {
                        TextBox t = (TextBox)c;
                        t.ReadOnly = true;
                        t.BackColor = System.Drawing.Color.WhiteSmoke;
                        t.BorderStyle = BorderStyle.None;
                    }
                }




            }
            else
            {
                ControlVisibility();

            }
        }
        catch (Exception ex)
        {
            if (log.IsErrorEnabled)
            {
                log.Error(ex.Message);
            }
        }
    }

    private void JobTitle()
    {
        try
        {
            EmpBL empBL = new EmpBL();
            ArrayList JobTitle = empBL.JobTitle();

            ListItem listItem = null;

            for (int i = 0; i < JobTitle.Count; i = i + 2)
            {
                listItem = new ListItem();
                listItem.Value = JobTitle[i].ToString();
                listItem.Text = JobTitle[i + 1].ToString();
                listItem.Attributes.Add("title", listItem.Text);

                ddlJobTitle.Items.Add(listItem);
            }
            ddlJobTitle.Items.Insert(0, "");

        }
        catch (Exception ex)
        {
            if (log.IsErrorEnabled)
            {
                log.Error(ex.Message);
            }
        }

    }

    private void ResidenceStatus()
    {
        try
        {
            EmpBL empBL = new EmpBL();
            ArrayList RStatus = empBL.ResidenceStatus();

            ListItem listItem = null;

            for (int i = 0; i < RStatus.Count; i = i + 2)
            {
                listItem = new ListItem();
                listItem.Value = RStatus[i].ToString();
                listItem.Text = RStatus[i + 1].ToString();
                listItem.Attributes.Add("title", listItem.Text);

                ddlResidenceStatus.Items.Add(listItem);
            }
            ddlResidenceStatus.Items.Insert(0, "");
        }
        catch (Exception ex)
        {
            if (log.IsErrorEnabled)
            {
                log.Error(ex.Message);
            }
        }

    }

    private void Country()
    {

        try
        {
            EmpBL empBL = new EmpBL();
            ArrayList country = empBL.Nationality();

            ListItem listItem = null;

            for (int i = 0; i < country.Count; i = i + 2)
            {
                listItem = new ListItem();
                listItem.Value = country[i].ToString();
                listItem.Text = country[i + 1].ToString();
                listItem.Attributes.Add("title", listItem.Text);

                ddlNationality.Items.Add(listItem);

            }
            ddlNationality.Items.Insert(0, "");

        }
        catch (Exception ex)
        {
            if (log.IsErrorEnabled)
            {
                log.Error(ex.Message);
            }

        }
    }

    private void MaritalStatus()
    {
        try
        {
            EmpBL empBL = new EmpBL();
            ArrayList MStatus = empBL.MaritalSatus();

            ListItem listItem = null;

            for (int i = 0; i < MStatus.Count; i = i + 2)
            {
                listItem = new ListItem();
                listItem.Value = MStatus[i].ToString();
                listItem.Text = MStatus[i + 1].ToString();
                listItem.Attributes.Add("title", listItem.Text);

                ddlMaritalStatus.Items.Add(listItem);
            }
            ddlMaritalStatus.Items.Insert(0, "");

        }
        catch (Exception ex)
        {
            if (log.IsErrorEnabled)
            {
                log.Error(ex.Message);
            }
        }

    }

    private void ControlVisibility()
    {
        imgFileUpload.Visible = true;
        imgExpiryDateCalender.Visible = true;
        imgTerminationDateCalender.Visible = true;
        imgJoiningDateCalendar.Visible = true;
        imgPayrollDate.Visible = true;
        imgBirthDate.Visible = true;
        ddlJobTitle.Visible = true;
        ddlMaritalStatus.Visible = true;
        ddlNationality.Visible = true;
        ddlResidenceStatus.Visible = true;
        ddlEmpType.Visible = true;
        txtJobTitle.Visible = false;
        txtMStatus.Visible = false;
        txtNationality.Visible = false;
        txtRStatus.Visible = false;
        txtEmpType.Visible = false;
        btnSave.Visible = true;
        btnEdit.Visible = false;
        btnCancel.Visible = true;
        rbnFemale.Enabled = true;
        rbnMale.Enabled = true;
        rbnMNo.Enabled = true;
        rbnMYes.Enabled = true;
        rbnNo.Enabled = true;
        rbnYes.Enabled = true;
        txtpswrd.Visible = true;
        lblPswrd.Visible = true;
        lblRetype.Visible = true;
        lblRetypemand.Visible = true;
        lblPswrdmand.Visible = true;
        txtRetypePswrd.Visible = true;
        txtEmail.Visible = true;
        //txtEmployeId.ReadOnly = true;
        //btnAddDesg.Visible = true;
    }

    private void EmployeeType()
    {
        EmpBL empBL = new EmpBL();
        DataSet ds = empBL.EmployeeType();
        ddlEmpType.DataSource = ds;
        ddlEmpType.DataTextField = "EmployeeType";
        ddlEmpType.DataValueField = "TypeId";
        ddlEmpType.DataBind();
        ddlEmpType.Items.Insert(0, "");
    }

    private void SendMail()
    {
        SmtpClient smtpClient = new SmtpClient();
        MailMessage message = new MailMessage();
        StringBuilder sb = new StringBuilder();
        sb.Append("Hi "+txtFirstName.Text+",");
        sb.AppendLine();
        sb.AppendLine();
        sb.Append("Welcome to HRMS.");
        sb.AppendLine();
        sb.AppendLine();
        sb.Append("Login Account has been created for you and the following are the details:");
        sb.AppendLine();
        sb.AppendLine();
        sb.Append("URL          :  http://hrms.s2tech.net/");
        //sb.Append("URL          :  http://s2hrm.s2tech.net/");
        sb.AppendLine();
        sb.Append("UserId       :  "+txtEmployeId.Text);
        sb.AppendLine();
        sb.Append("Password     :  " +txtpswrd.Text);
        sb.AppendLine();
        sb.AppendLine();
        sb.Append("Please contact HR Manager if you have any questions.");
        sb.AppendLine();
        sb.AppendLine();
        sb.Append("Thanks");
        sb.AppendLine();
        sb.Append("HR Manager");
        message.Body = sb.ToString();
        message.From = new MailAddress(Session["EmailId"].ToString());
        message.Subject = "HRMS Login Credentials";
        message.To.Add(txtEmail.Text);
        smtpClient.Send(message);
    }



    #endregion

    //#region UserControl
    //private void FillGridbySearch()
    //{
    //    DataSet ds;
    //    string searchvalue = txtSearch.Text;
    //    index = ddlSearch.SelectedIndex;
    //    string empId = string.Empty;
    //    EmpBL empBL = new EmpBL();
    //    GVEmpInfo.Visible = true;
    //    ds = empBL.GetEmployeeInformation(index, searchvalue, empId, 0);
    //    GVEmpInfo.DataSource = ds;
    //    GVEmpInfo.DataBind();
    //}
    //protected void btnSearch_Click(object sender, EventArgs e)
    //{
    //    FillGridbySearch();
    //}

    //protected void rbtnCheck_CheckedChanged(object sender, EventArgs e)
    //{
    //    try
    //    {
    //        foreach (GridViewRow oldrow in GVEmpInfo.Rows)
    //        {
    //            ((RadioButton)oldrow.FindControl("rbtnCheck")).Checked = false;

    //        }
    //        RadioButton rb = (RadioButton)sender;
    //        rb.Checked = true;
    //        string rbtnId = rb.UniqueID.ToString();
    //        int rowindex = Convert.ToInt32(rbtnId.Substring(rbtnId.LastIndexOf("$") - 2, 2));
    //        string employeeId = ((Label)GVEmpInfo.Rows[rowindex - 2].FindControl("lblEmployeeID")).Text;
    //        Session["searchId"] = employeeId;
    //        hdnTest.Value = employeeId;
    //        //txtEmployeId.Text = employeeId;
    //        hdnEdit.Value = string.Empty;
    //        RetrieveEmpInfo();
    //    }
    //    catch (Exception ex)
    //    {
    //        if (log.IsErrorEnabled)
    //        {
    //            log.Error(ex.Message);
    //        }
    //    }
    //}

    //public void Search()
    //{
    //    try
    //    {
    //        EmpBL empBL = new EmpBL();
    //        ArrayList search = empBL.Search();

    //        ListItem listItem = null;

    //        for (int i = 0; i < search.Count; i = i + 2)
    //        {
    //            listItem = new ListItem();
    //            listItem.Value = search[i].ToString();
    //            listItem.Text = search[i + 1].ToString();
    //            listItem.Attributes.Add("title", listItem.Text);

    //            ddlSearch.Items.Add(listItem);

    //        }
    //        ddlSearch.SelectedValue = "2";
    //    }
    //    catch (Exception ex)
    //    {
    //    }
    //}

    //protected void btnClear_Click(object sender, EventArgs e)
    //{

    //    txtSearch.Text = string.Empty;
    //    ddlSearch.SelectedValue = "2";
    //   hdnTest.Value = Session["EmployeeID"].ToString();
    //    RetrieveEmpInfo();
    //    GVEmpInfo.Visible = false;
    //}

    private void ClearControls()
    {
        foreach (Control c in pnlPersonal.Controls)
        {
            if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
            {
                TextBox t = (TextBox)c;
                t.ReadOnly = false;
                t.BackColor = System.Drawing.Color.White;
                t.BorderStyle = BorderStyle.NotSet;
                t.Text = string.Empty;


            }
        }
        foreach (Control c in tblPersonal.Controls)
        {
            if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
            {
                TextBox t = (TextBox)c;
                t.ReadOnly = false;
                t.BackColor = System.Drawing.Color.White;
                t.BorderStyle = BorderStyle.NotSet;
                t.Text = string.Empty;
            }
        }
    }
    //#endregion
}
#endregion
Posted
Updated 4-Feb-11 3:13am
v6

1 solution

C#
// Button is invisible per default and will only be seen when details are empty or User is ADMIN or HR
editButton.Visible = false;
if( (IsEmpty(user.Details) && user == InfoPage.User) || user.Role == Users.ADMIN || user.Role == Users.HR)
{
    editButton.Visible = true;
}


Cheers!
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900