Esempio n. 1
0
    protected void btnEmployeeAdd_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtEmployeeCompanyName.Text == "")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('Wrong Flat ID')", true);
                return;
            }

            String CompanyName = txtEmployeeCompanyName.Text;


            int SetrviceType = Convert.ToInt32(drpServiceType.SelectedValue);



            int UserID = ExistingUserID;

            String ResidentType = "Employee";

            Resident res = new Resident();

            res.UserID       = ExistingUserID;
            res.FlatID       = 0;
            res.SocietyID    = muser.currentResident.SocietyID;
            res.Status       = 2;
            res.UserType     = ResidentType;
            res.ServiceType  = SetrviceType;
            res.DeActiveDate = DateTime.UtcNow.AddYears(5);

            if (!res.IsUserExist())
            {
                bool result = res.AddSocietyUser();
                if (result)
                {
                    FillEmployeeData();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:hideAddEmployeeModal()", true);
                }
                else
                {
                    lblUserCheck.Text = "Error Updating Employee";
                }
            }
            else
            {
                lblUserCheck.Text = "Employee already Exist";
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert(Error)", true);
        }
    }