コード例 #1
0
    protected void btnSaveRecord_Click(object sender, EventArgs e)
    {
        List<Entity.CompanyInfo> oListCompanyInfo = new List<Entity.CompanyInfo>();
        Entity.CompanyInfo oCompanyInfo;

        string[] strEmailArray = new string[gvRequestedUser.Rows.Count];
        int i = 0;
        foreach (GridViewRow gvr in gvRequestedUser.Rows)
        {
            Label lblEmpEmail = (Label)gvr.FindControl("lblEmpEmail");
            if (lblEmpEmail != null && lblEmpEmail.Text != string.Empty)
            {
                strEmailArray[i] = lblEmpEmail.Text;
                i = i + 1;
            }
        }

        oCompanyManager = new BLL.CompanyManager();
        if (!oCompanyManager.IsEmailIdExists(strEmailArray))
        {
            oCompanyManager = null;
            lblMsg.Text = "<br /><br/>Please check the email addresses.  Multiple entries are not allowed.";
            ReadXML();
            return;
        }

        oCompanyManager = null;
        try
        {
            foreach (GridViewRow gvr in gvRequestedUser.Rows)
            {
                Label lblEmpfName = (Label)gvr.FindControl("lblEmpfName");
                Label lblEmpLName = (Label)gvr.FindControl("lblEmpLName");
                Label lblEmpEmail = (Label)gvr.FindControl("lblEmpEmail");

                oCompanyInfo = new Entity.CompanyInfo();
                oCompanyInfo.IntCompanyId = AppLib.GetLoggedInUserId();
                oCompanyInfo.StrEmployeeAddress = "";

                oCompanyInfo.StrEmpCode = "";
                oCompanyInfo.StrEmpFirstName = lblEmpfName.Text.Trim();
                oCompanyInfo.StrEmpLastName = lblEmpLName.Text.Trim();
                oCompanyInfo.StrEmpMiddleName = "";
                oCompanyInfo.StrEmpEmail = lblEmpEmail.Text.Trim();
                oCompanyInfo.ChrStatus = 'I';
                oCompanyInfo.DtCreatedDate = DateTime.Now;

                oListCompanyInfo.Add(oCompanyInfo);
                oCompanyInfo = null;
            }
        }
        catch { }

        try
        {
            if (oListCompanyInfo.Count > 0)
            {
                oCompanyManager = new BLL.CompanyManager();
                oCompanyManager.SaveRequestCompanyForUserRegistration(oListCompanyInfo);
                oCompanyManager = null;
                SendUserRegistrationEmailtoAdmin();
                lblMsg.Text = "<br /><br />Thank you.  Check back for status of your employees.<br /><br /><br />";
            }
        }
        catch(Exception ex) {

            lblMsg.Text = "<br /><br />There was an error with your request.  Please contact TLW directly.<br /><br /><br />";
        }
        oCompanyInfo = null;

        oListCompanyInfo = null;
    }