protected void btnDelete_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            UserLoginDTO userLogin = getUserLogin();
            ConnectionData.OpenMyConnection();
            int Id = int.Parse(((ImageButton)sender).CommandArgument.ToString());
            mcBUS = new MailConfigBUS();
            SendRegisterBUS srBUS = new SendRegisterBUS();

            if (srBUS.GetByMailConfigID(Id) > 0)
            {
                visibleMessage(false);
                pnError.Visible = true;
                lblError.Text = "Bạn vừa không thể xóa cấu hình này được. Cấu hình này đang có mail chờ gửi !";

            }
            else
            {
               int IDCurrent = userLogin.UserId;
               if (Id != IDCurrent)
               {
                   mcBUS.tblMailConfig_Delete(Id);
                   //Response.Redirect(Request.RawUrl);
                   dlMailConfig.DataSource = mcBUS.GetAll();
                   dlMailConfig.DataBind();
                   visibleMessage(false);
                   pnSuccess.Visible = true;
                   lblSuccess.Text = "Bạn vừa xóa thành một cấu hình !";
               }
               else
               {
                   visibleMessage(false);
                   pnError.Visible = true;
                   lblError.Text = "Bạn vừa không thể xóa cấu hình này được. Cấu hình này đang là cấu hình bạn đang đăng nhập!";
               }
            }
            ConnectionData.CloseMyConnection();
        }
        catch (Exception ex)
        {
            //pnError.Visible = true;
            //lblError.Text = ex.Message;
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        ci = new CultureInfo("vi-VN");
        try
        {
            if (CheckValidate() == "")
            {
                mcBUS = new MailConfigBUS();
                ConnectionData.OpenMyConnection();
                if (getUserLogin().DepartmentId == 1)
                {
                    mcBUS.tblMailConfig_insert(GetMailConfigDTO());
                    ConnectionData.CloseMyConnection();
                    pnSuccess.Visible = true;
                    //lblSuccess.Text = this.GetGlobalResourceObject("Resource", "InsertSucces").ToString();
                    Resources.Resource.Culture = ci;
                    lblSuccess.Text = Resources.Resource.InsertSucces;
                    dlMailConfig.DataSource = mcBUS.GetAll();
                    dlMailConfig.DataBind();
                    pnError.Visible = false;
                }
                else
                {
                    this.btnSave.Enabled = false;
                    pnError.Visible = true;
                    lblError.Text = Resources.Resource.InsertFail;
                    Resources.Resource.Culture=ci;

                }
            }
            else
            {
                pnError.Visible = true;
                lblError.Text = CheckValidate();
                pnSuccess.Visible = false;
            }

        }
        catch (Exception ex)
        {
            pnError.Visible = true;
            lblError.Text = "Vui lòng kiểm tra lại cấu hình mail.<br/>" + ex.Message;
        }
    }
 private void InitBUS()
 {
     mcBUS = new MailConfigBUS();
     dpBUS = new DepartmentBUS();
     if (getUserLogin().DepartmentId == 1)
     {
         drlDepartmen.Items.Clear();
         drlDepartmen.DataSource = dpBUS.GetAll();
         drlDepartmen.DataTextField = "Name";
         drlDepartmen.DataValueField = "ID";
         drlDepartmen.DataBind();
         dlMailConfig.DataSource = mcBUS.GetAll();
         dlMailConfig.DataBind();
     }
     else
     {
         this.btnSave.Enabled = false;
     }
 }
예제 #4
0
 private void LoadMailConfigLists()
 {
     mailConfigBus = new MailConfigBUS();
     DataTable dtMailConfig = new DataTable();
     UserLoginDTO userLogin = getUserLogin();
     if (userLogin != null)
     {
         if (userLogin.DepartmentId == 1)
         {
             dtMailConfig = mailConfigBus.GetAll();
         }
         else
         {
             dtMailConfig = mailConfigBus.GetByUserId(userLogin.UserId);
         }
     }
     else
     {
         Response.Redirect("login.aspx", false);
     }
     drlMailConfig.Items.Clear();
     drlMailConfig.DataSource = dtMailConfig.DefaultView;
     drlMailConfig.DataTextField = "Email";
     drlMailConfig.DataValueField = "Id";
     drlMailConfig.DataBind();
 }