Ejemplo n.º 1
0
    /*Sub Header***********************************************************
    Function Name: BindCompanyStatusDropdown
    Functionality: This function is used to bind the company statuses with the predefined array

    Input: dropdownlist and the strInitialText
    Output:
    Note:
    *********************************************************************/
    public static void BindCompanyCheckBoxList(CheckBoxList ddList, string strInitialText)
    {
        BLL.CompanyManager oCompanyManager = new BLL.CompanyManager();

        ddList.DataSource = oCompanyManager.GetCompanyAllCompanies();
        ddList.DataTextField = "strCompanyName";
        ddList.DataValueField = "intCompanyId";
        ddList.DataBind();

        ListItem lstInitialItem;
        if (strInitialText.Trim() != "")
        {
            lstInitialItem = new ListItem(strInitialText, "0");
            ddList.Items.Insert(0, lstInitialItem);
        }
        lstInitialItem = null;
        oCompanyManager = null;
    }
    protected void lnkBtnUpdate_Click(object sender, EventArgs e)
    {
        BLL.CompanyManager oCompanyManager = new BLL.CompanyManager();
        List<Entity.CompanyInfo> oListCompanyInfo = new List<Entity.CompanyInfo>();
        Entity.CompanyInfo oCompanyInfo = new Entity.CompanyInfo();
        switch (ddlToEmails.SelectedValue)
        {
            case "0":/*send email to all the users*/
                {
                    oListCompanyInfo = oCompanyManager.GetAllUsers();
                    if (oListCompanyInfo.Count > 0)
                    {
                        foreach (var item in oListCompanyInfo)
                        {
                            AppLib.SendMailToUser(item.StrEmpEmail, txtSubject.Text, reContent.Content, txtFromEmail.Text);
                        }
                    }
                    oCompanyManager = null;
                    oListCompanyInfo = null;
                    break;
                }
            case "1":/*send email to all companies*/
                {
                    oListCompanyInfo = oCompanyManager.GetCompanyAllCompanies();
                    if (oListCompanyInfo.Count > 0)
                    {
                        foreach (var item in oListCompanyInfo)
                        {
                            AppLib.SendMailToUser(item.StrEmpEmail, txtSubject.Text, reContent.Content, txtFromEmail.Text);
                        }
                    }
                    break;
                }
            case "2":/* send email to single companies*/
                {
                    oCompanyInfo = oCompanyManager.GetCompanyDetailsById(Convert.ToInt32(ddlCompany.SelectedValue));
                    if (oCompanyInfo != null)
                    {
                        AppLib.SendMailToUser(oCompanyInfo.StrCompanyEmail, txtSubject.Text, reContent.Content,txtFromEmail.Text);
                    }
                    break;
                }
            case "3":/*send email to all the users of the company*/
                {
                    oListCompanyInfo = oCompanyManager.GetUsersByCompanyId(Convert.ToInt32(ddlCompany.SelectedValue));
                    foreach (var item in oListCompanyInfo)
                    {
                        AppLib.SendMailToUser(item.StrEmpEmail, txtSubject.Text, reContent.Content, txtFromEmail.Text);
                    }

                    break;
                }
            case "4":/*send email to single user of the compan*/
                {
                    AppLib.SendMailToUser(ddlUsers.SelectedItem.Text, txtSubject.Text, reContent.Content, txtFromEmail.Text);
                    break;
                }
            default:
                {
                    break;
                }
        }

        lblMsg.Text = "Email(s) has been successfully sent. ";
        txtSubject.Text = string.Empty;
        reContent.Content = string.Empty;
        oCompanyManager = null;
        oCompanyInfo = null;
        oListCompanyInfo = null;
    }