Ejemplo n.º 1
0
    protected void btnEdit_Click(object sender, ImageClickEventArgs e)
    {
        pnError.Visible = false;
        pnSuccess.Visible = false;
        try
        {
            int UserId = int.Parse((((ImageButton)sender).CommandArgument.ToString()));
            ulBus = new UserLoginBUS();
            DataTable table = ulBus.GetByUserId(UserId);
            if (table.Rows.Count > 0)
            {
                txtUsername.Text = table.Rows[0]["Username"].ToString();
                txtUsername.Enabled = false;
                dropTypeUser.SelectedValue = table.Rows[0]["DepartmentId"].ToString();
                bool checkBlock =bool.Parse(table.Rows[0]["Is_Block"].ToString());

                chkBlock.Checked = checkBlock;

                this.hdfId.Value = UserId + "";

            }

        }
        catch (Exception ex)
        {
            logs.Error(userLogin.Username + "-Client - btnEdit_Click", ex);
            pnError.Visible = false;
            pnSuccess.Visible = false;
        }
    }
Ejemplo n.º 2
0
    private void getUserInfo()
    {
        UserLoginBUS ulBus = new UserLoginBUS();
        DepartmentBUS dBus = new DepartmentBUS();
        RoleDetailBUS rdBus = new RoleDetailBUS();

        int userId = int.Parse(Request.QueryString["uid"].ToString());
        DataTable tblUserDetail = Common.GetUserLoginDetail(userId);

        DataTable tblSendRegisterDetailByUser = Common.GetSendRegisterByUserId(userId);
        DataTable tblCustomerCreated = Common.GetCustomerCreatedByUserId(userId);

        if (tblUserDetail.Rows.Count > 0)
        {
            int departId = int.Parse(tblUserDetail.Rows[0]["DepartmentId"].ToString());
            DataTable tblRoleDetail = rdBus.GetByDepartmentId(departId);

            lblUsername.Text = tblUserDetail.Rows[0]["Username"].ToString();
            lblDepartment.Text = tblUserDetail.Rows[0]["Name"].ToString();

            if(tblRoleDetail.Rows.Count>0){
                lblHasSend.Text =
                    tblSendRegisterDetailByUser.Rows.Count + " / " + tblRoleDetail.Rows[0]["limitSendMail"].ToString();
                lblHasCustomerCreate.Text =
                    tblCustomerCreated.Rows.Count + " / " + tblRoleDetail.Rows[0]["limitCreateCustomer"].ToString();
                lblToDate.Text = tblRoleDetail.Rows[0]["toDate"].ToString();
            }

        }
    }
Ejemplo n.º 3
0
    protected void lbtChangPass_Click(object sender, EventArgs e)
    {
        UserLoginDTO userLogin = getUserLogin();
        string message = checkInput();
        if (message == "")
        {
            UserLoginBUS ulBus = new UserLoginBUS();
            string newPass = Common.GetMd5Hash(txtNewPass.Text.Trim());
            userLogin.Password = newPass;
            ConnectionData.OpenMyConnection();
            ulBus.tblUserLogin_Update(userLogin);
            ConnectionData.CloseMyConnection();
            //update session userlogin info
            Session["us-login"] = userLogin;

            pnSuccess.Visible = true;
            pnError.Visible = false;
            lblSuccess.Text = "Đã thay đổi mật khẩu thành công !";
        }
        else
        {
            pnSuccess.Visible = false;
            pnError.Visible = true;
            lblError.Text = message;
        }
    }
Ejemplo n.º 4
0
    protected void btnDelete_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            int subId = int.Parse((((ImageButton)sender).CommandArgument.ToString()));
            ulBus = new UserLoginBUS();
            ConnectionData.OpenMyConnection();

            // DataTable table = ulBus.GetUserIdBySubID(subId);
            //  int UserId = int.Parse(table.Rows[0]["UserId"].ToString());

            DataTable table = ulBus.GetBySubId(subId);
            string Username = table.Rows[0]["subEmail"].ToString();

            ulBus.tblUserLoginSub_Delete(Username);

            ulBus.tblSubClient_Delete(subId);

            //lay UserID

            ConnectionData.CloseMyConnection();
            pnError.Visible = false;
            pnSuccess.Visible = true;
            lblSuccess.Text = "Xóa thành công !";
        }
        catch (Exception ex)
        {
            pnError.Visible = true;
            lblError.Text = "Không thể xóa !</br>" + ex.Message;
            logs.Error(userLogin.Username + "subClient-Delete", ex);
        }
        LoadData();
    }
Ejemplo n.º 5
0
    protected void btnEdit_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            pnSuccess.Visible = false;
            pnError.Visible = false;
            int subId = int.Parse((((ImageButton)sender).CommandArgument.ToString()));
            ulBus = new UserLoginBUS();
            DataTable table = ulBus.GetBySubId(subId);
            string Username = table.Rows[0]["subEmail"].ToString();
            DataTable dtIsBlock = ulBus.GetIsBlockByUserId(Username);
            if (table.Rows.Count > 0)
            {
                txtUsername.Text = table.Rows[0]["subName"].ToString();
                txtUsername.Enabled = false;
                txtEmail.Text = table.Rows[0]["subEmail"].ToString();
                txtEmail.Enabled = false;
                bool checkBlock = bool.Parse(dtIsBlock.Rows[0]["Is_Block"].ToString());

                chkBlock.Checked = checkBlock;

                this.hdfId.Value = subId + "";

            }

        }
        catch (Exception ex)
        {
            pnError.Visible = false;
            logs.Error(userLogin.Username + "subClient-Edit", ex);
        }
    }
Ejemplo n.º 6
0
 protected void btnDelete_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         int UserId = int.Parse((((ImageButton)sender).CommandArgument.ToString()));
         ulBus = new UserLoginBUS();
         ConnectionData.OpenMyConnection();
         ulBus.tblUserLogin_Delete(UserId);
         ConnectionData.CloseMyConnection();
         pnError.Visible = false;
         pnSuccess.Visible = true;
         lblSuccess.Text = "Xóa thành công !";
     }
     catch (Exception ex)
     {
         logs.Error(userLogin.Username + "-Client - btnDelete_Click", ex);
         pnError.Visible = true;
         lblError.Text = "Không thể xóa !</br>" + ex.Message;
     }
     LoadData();
 }
Ejemplo n.º 7
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string message = "";
        try
        {
            if (hdfId.Value == null || hdfId.Value == "")//them moi
            {
                message = checkInput();
            }
            else
            {
                message = checkPassword();
            }
            int status = 0;
            if (message == "")
            {

                ulBus = new UserLoginBUS();
                UserLoginDTO ulDto = new UserLoginDTO();
                ulDto.Username = txtUsername.Text;
                ulDto.Password = Common.GetMd5Hash(txtPassword.Text);
                ulDto.DepartmentId = int.Parse(this.dropTypeUser.SelectedItem.Value.ToString());
                DataTable dtLogin = ulBus.GetByUserType(ulDto.DepartmentId);
                ulDto.UserType =int.Parse(dtLogin.Rows[0]["UserType"].ToString());
                ulDto.Is_Block = this.chkBlock.Checked;
                ulDto.Deleted = 0;
                ConnectionData.OpenMyConnection();
                if (hdfId.Value == null || hdfId.Value == "")//them moi
                {
                    ulBus.tblUserLogin_insert(ulDto);
                    status = 1;
                }
                else
                {

                        ulDto.UserId = int.Parse(hdfId.Value);
                        ulBus.tblUserLogin_Update(ulDto);
                        status = 2;

                }

                ConnectionData.CloseMyConnection();
                pnSuccess.Visible = true;
                pnError.Visible = false;
                LoadData();
                if (status == 1)
                {
                    lblSuccess.Text = "Thêm thành công !";
                }
                else
                    if (status == 2)
                    {
                        lblSuccess.Text = "Bạn vừa cập nhật thành công chức năng !";
                        txtUsername.Enabled = true;
                    }

            }
            else
            {
                pnSuccess.Visible = false;
                pnError.Visible = true;
                lblError.Text = message;
            }

        }
        catch (Exception ex)
        {

            logs.Error(userLogin.Username + "-Client - btnSave_Click", ex);
            pnSuccess.Visible = false;
            pnError.Visible = true;
            lblError.Text = "Kiểm tra lại dữ liệu nhập vào !";
        }
    }
Ejemplo n.º 8
0
    private void LoadData()
    {
        try
        {
            DataTable dtLogin = null;
            ulBus = new UserLoginBUS();
            //if (getUserLogin().DepartmentId == 1)
            //{
                dtLogin = ulBus.GetAll();
            //}
            //else
            //{
            //    dtLogin = ulBus.GetAllByUserId(getUserLogin().UserId);

            //}
            dlMember.DataSource = dtLogin;
            dlMember.DataBind();

            DataTable dtUserType = ulBus.GetByUserId(getUserLogin().UserId);
            int UserType = int.Parse(dtUserType.Rows[0]["UserType"].ToString());
            deBus = new DepartmentBUS();
            dropTypeUser.Items.Clear();

            dropTypeUser.DataSource = deBus.GetByUserType(UserType);
            dropTypeUser.DataTextField = "Name";
            dropTypeUser.DataValueField = "ID";
            dropTypeUser.DataBind();

            for (int i = 0; i < dtLogin.Rows.Count; i++)
            {
                Label lblNo = (Label)(Label)dlMember.Items[i].FindControl("No");
                lblNo.Text = (i + 1).ToString();
            }

        }
        catch (Exception ex)
        {

            logs.Error(userLogin.Username + "-Client - LoadData", ex);
        }
    }
Ejemplo n.º 9
0
    protected void loadUserByDepartmentId(int departId)
    {
        ulBus = new UserLoginBUS();
        deBus = new DepartmentBUS();
        DataTable dtLogin = ulBus.GetByDepartmentId(departId);

        dlMember.DataSource = dtLogin;
        dlMember.DataBind();
        for (int i = 0; i < dtLogin.Rows.Count; i++)
        {
            DataRow row = dtLogin.Rows[i];

            Label lblUsername = (Label)dlMember.Items[i].FindControl("lblUsername");
            lblUsername.Text = row["Username"].ToString();

            Label lblDepartment = (Label)dlMember.Items[i].FindControl("lblDepartment");
            DataTable dtDepartment = deBus.GetByID(int.Parse(row["DepartmentId"].ToString()));
            if (dtDepartment.Rows.Count > 0)
            {
                lblDepartment.Text = dtDepartment.Rows[0]["Name"].ToString();

            }

            LinkButton lbtEdit = (LinkButton)dlMember.Items[i].FindControl("lbtEdit");
            lbtEdit.CommandArgument = row["UserId"].ToString();

            LinkButton lbtDelete = (LinkButton)dlMember.Items[i].FindControl("lbtDelete");
            lbtDelete.CommandArgument = row["UserId"].ToString();

            LinkButton lbtViewDetail = (LinkButton)dlMember.Items[i].FindControl("lbtViewDetail");
            lbtViewDetail.CommandArgument = row["UserId"].ToString();
            lbtViewDetail.PostBackUrl = "user-detail.aspx?uid=" + row["UserId"].ToString();
            if (row["Username"].Equals("administrator"))
            {
                lbtDelete.Visible = false;
                lbtEdit.Visible = false;
                lbtViewDetail.Visible = false;
            }

        }
    }
Ejemplo n.º 10
0
 protected bool checkExistUsername(string username)
 {
     ulBus = new UserLoginBUS();
     DataTable tblUser = ulBus.GetByUsername(username);
     if (tblUser.Rows.Count > 0)
     {
         return true;
     }
     return false;
 }
Ejemplo n.º 11
0
    private void LoadData()
    {
        try
        {
            DataTable dtLogin = null;
            ulBus = new UserLoginBUS();
            DataTable table = ulBus.GetClientId(getUserLogin().UserId);
            int clienID = int.Parse(table.Rows[0]["clientId"].ToString());
            if (getUserLogin().DepartmentId == 1)
            {
                dtLogin = ulBus.GetSubClient();
            }
            else if (getUserLogin().DepartmentId == 3)
            {
                dtLogin = ulBus.GetSubClientDepart3(getUserLogin().UserId);
            }
            if (getUserLogin().DepartmentId == 2)
            {
                dtLogin = ulBus.GetSubClientUserID(clienID);
            }
            dlMember.DataSource = dtLogin;
            dlMember.DataBind();

            for (int i = 0; i < dtLogin.Rows.Count; i++)
            {
                Label lblNo = (Label)(Label)dlMember.Items[i].FindControl("No");
                lblNo.Text = (i + 1).ToString();
            }

        }
        catch (Exception ex)
        {

            logs.Error(userLogin.Username + "-Client - LoadData", ex);
        }
    }
Ejemplo n.º 12
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        DataTable table = null;
        string message = "";
        try
        {
            if (hdfId.Value == null || hdfId.Value == "")//them moi
            {
                message = checkInput();
            }
            else
            {
                message = checkPassword();
            }
            int status = 0;
            if (message == "")
            {

                ulBus = new UserLoginBUS();
                UserLoginDTO ulDto = new UserLoginDTO();
                ulDto.Username = txtUsername.Text;
                ulDto.Password = Common.GetMd5Hash(txtPassword.Text);
                ulDto.Email = txtEmail.Text;
                ulDto.Is_Block = this.chkBlock.Checked;
                ulDto.UserType = 2;
                //tai khoan con ID =3
                ulDto.UserId = 3;
                ConnectionData.OpenMyConnection();
                if (hdfId.Value == null || hdfId.Value == "")//them moi
                {

                    if (getUserLogin().DepartmentId == 3)
                    {
                        table = ulBus.GetClientIdSub(getUserLogin().UserId);
                    }
                    else
                    {
                        table = ulBus.GetClientId(getUserLogin().UserId);
                    }

                    int clienID = int.Parse(table.Rows[0]["clientId"].ToString());
                    ulDto.ClientID = clienID;

                    int statusclient = int.Parse(table.Rows[0]["Status"].ToString());

                    DataTable countSubClient = ulBus.GetCountSubClient(ulDto.ClientID);
                    int countSub = int.Parse(countSubClient.Rows[0]["numberSub"].ToString());

                    DataTable subAccount = ulBus.GetSubAccountCount(ulDto.ClientID);
                    int SubAccount = int.Parse(subAccount.Rows[0]["subAccontCount"].ToString());

                    DateTime NgayHetHan = Convert.ToDateTime(table.Rows[0]["expireDate"].ToString());
                    string todays = DateTime.Now.ToString("yyyy-MM-dd");
                    DateTime today = Convert.ToDateTime(todays);
                    DateTime expireDay = Convert.ToDateTime(NgayHetHan);
                    DataTable checkEmail = ulBus.GetEmailByUser(txtEmail.Text.Trim());
                    if (statusclient == 2 || expireDay < today)
                    {
                        status = 3;
                    }
                    else
                    {
                        if (countSub < SubAccount)
                        {
                            if (checkEmail.Rows.Count > 0)
                            {
                                status = 5;
                            }
                            else
                            {
                                ulBus.tblUserLoginSubClient_insert(ulDto);
                                //lay UserID
                                DataTable dt = ulBus.GetUserIDByUserName(txtEmail.Text);
                                int userID = int.Parse(dt.Rows[0]["UserId"].ToString());
                                ulDto.UserId = userID;
                                ulBus.tblSubClient_insert(ulDto);
                                status = 1;
                            }
                        }
                        else
                        {
                            status = 4;
                        }
                    }

                }
                else
                {

                    ulDto.SubId = int.Parse(hdfId.Value);
                    DataTable checkEmail = ulBus.GetEmailByUser(txtEmail.Text.Trim());
                    if (checkEmail.Rows.Count > 0)
                    {
                        status = 5;
                    }
                    else
                    {
                        ulBus.tblSubClient_Update(ulDto);
                        // DataTable table1 = ulBus.GetUserIdBySubID(ulDto.SubId);
                        // int userID = int.Parse(table1.Rows[0]["UserID"].ToString());
                        DataTable tablesub = ulBus.GetBySubId(ulDto.SubId);
                        string Username = tablesub.Rows[0]["subEmail"].ToString();
                        DataTable dtIsBlock = ulBus.GetIsBlockByUserId(Username);
                        bool Is_Block_check = chkBlock.Checked;
                        ulBus.tblUserLoginSub_Update(Username, Is_Block_check);
                        status = 2;
                    }

                }

                ConnectionData.CloseMyConnection();
                pnSuccess.Visible = true;
                pnError.Visible = false;
                LoadData();
                if (status == 5)
                {
                    pnSuccess.Visible = false;
                    pnError.Visible = true;
                    lblError.Text = "Email đã được sử dụng. Vui lòng chọn email khác !";
                    this.txtEmail.Focus();
                }
                if (status == 4)
                {
                    lblError.Text = "Tạo tài khoản con vượt quá giới hạn cho phép!";
                    pnSuccess.Visible = false;
                    pnError.Visible = true;
                }
                if (status == 3)
                {
                    lblError.Text = "Không cho phép tạo tài khoản con.Liên hệ quản trị!";
                    pnSuccess.Visible = false;
                    pnError.Visible = true;
                }
                if (status == 1)
                {
                    lblSuccess.Text = "Thêm thành công !";
                }
                else
                    if (status == 2)
                    {
                        lblSuccess.Text = "Bạn vừa cập nhật thành công chức năng !";
                        txtUsername.Enabled = true;
                    }

            }
            else
            {
                pnSuccess.Visible = false;
                pnError.Visible = true;
                lblError.Text = message;
            }

        }
        catch (Exception ex)
        {
            pnSuccess.Visible = false;
            pnError.Visible = true;
            lblError.Text = "Kiểm tra lại dữ liệu nhập vào !";
            logs.Error(userLogin.Username + "subClient-Save", ex);
        }
    }
Ejemplo n.º 13
0
    protected void updateLimitSendAndCreate(int hasCreatedCustomer, int countSend)
    {
        UserLoginDTO userLogin = getUserLogin();
        userLogin.hasCreatedCustomer = userLogin.hasCreatedCustomer + hasCreatedCustomer;
        userLogin.hasSendMail = userLogin.hasSendMail + countSend;
        Session["us-login"] = userLogin;

        // Update to DB
        UserLoginBUS ulBus = new UserLoginBUS();
        ulBus.tblUpdateSendMail(userLogin.UserId, userLogin.hasSendMail);
    }
Ejemplo n.º 14
0
    private void infoUpdate()
    {
        // Cap nhat so luong mail da gui.
        UserLoginBUS ulBus = new UserLoginBUS();
        int currentSend = int.Parse(hdfCountCustomer.Value);
        int hasSend = getUserLogin().hasSendMail;
        int currentHasSend = currentSend + hasSend;
        ulBus.tblUpdateSendMail(getUserLogin().UserId, currentHasSend);

        // Cap nhat session
        UserLoginDTO ulDto = getUserLogin();
        ulDto.hasSendMail = currentHasSend;
        Session["us-login"] = ulDto;
    }
Ejemplo n.º 15
0
 private void SendMail(CustomerDTO customerDto)
 {
     string eventId = Request.Params["eventId"];
     DataTable T = new EventBUS().GetByID(Convert.ToInt32(eventId));
     if (T != null && T.Rows.Count > 0)
     {
         DataTable user = new UserLoginBUS().GetByUserId(Convert.ToInt32(T.Rows[0]["userid"] + ""));
         SmtpClient SmtpServer = new SmtpClient();
         SmtpServer.Credentials = new System.Net.NetworkCredential("AKIAIGXHHO72FHXGCPFQ", "Ara8HV/kcfjNU+rqrTpJBAAjs/OsD1xEykLsuguqpe1Z");
         SmtpServer.Port = 25;
         SmtpServer.Host = "email-smtp.us-east-1.amazonaws.com";
         SmtpServer.EnableSsl = true;
         MailMessage mail = new MailMessage();
         //String[] addr = user.Rows[0]["username"].Split(' ');
         mail.From = new MailAddress("*****@*****.**",
         " Hệ Thống eMailMaketing  ", System.Text.Encoding.UTF8);
         //Byte i;
         //for (i = 0; i < addr.Length; i++)
         mail.To.Add(user.Rows[0]["username"]+"");
         mail.Subject = "Thư xác nhận";
         mail.IsBodyHtml = true;
         mail.Body = @"<html>
                         <head>
                             <title></title>
                         </head>
                         <body style=margin: 0px 0px 0px 0px>
                             <h3>Chào {0} thân mến!</h3>
                             Đã có khách hàng đăng ký nhận mail cho sự kiện '{6}' với thông tin như sau:
                             <br />
                             Họ tên: {1}
                             <br />
                             Địa chỉ email: {2}
                             <br />
                             Giới tính: {3}
                             <br />
                             Địa chỉ: {4}
                             <br />
                             Công ty: {5}
                         </body>
                         </html>
                         ";
         mail.Body = string.Format(mail.Body, user.Rows[0]["username"] + "", customerDto.Name, customerDto.Email, customerDto.Gender, customerDto.Address, customerDto.Country,T.Rows[0]["subject"]);
         mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
         mail.ReplyTo = new MailAddress(user.Rows[0]["username"] + "");
         SmtpServer.Send(mail);
     }
 }
Ejemplo n.º 16
0
 private void InitBUS()
 {
     ulBus = new UserLoginBUS();
     mgBUS = new MailGroupBUS();
     srBUS = new SendRegisterBUS();
     ctBUS = new CustomerBUS();
     dgBUS = new DetailGroupBUS();
 }
Ejemplo n.º 17
0
    protected void lbtChangeAdvance_Click(object sender, EventArgs e)
    {
        try
        {
            RoleDetailBUS rdBus = new RoleDetailBUS();
            PanelAdvance.Visible = false;
            int departmentId = int.Parse(hdfDepartmentId.Value);
            int limitSendMail = int.Parse(txtLimitMailSend.Text);
            string toDate = txtToDate.Text;
            int limitCreateCustomer = int.Parse(txtLimitCreateCustomer.Text);

            if (chkAdvance.Checked)
            {
                // Cap nhat voi hang ngach gui mail, tao khach hang.
                RoleDetailDTO rdDto = new RoleDetailDTO();
                rdDto.roleId = -1;
                rdDto.departmentId = departmentId;
                rdDto.limitSendMail = limitSendMail;
                rdDto.limitCreateCustomer = limitCreateCustomer;
                rdDto.toDate = convertStringToDate(toDate);
                ConnectionData.OpenMyConnection();
                int rsUpdate = rdBus.tblRoleDetail_Update(rdDto);
                ConnectionData.CloseMyConnection();
                if (rsUpdate <= 0)
                {
                    // Them voi hang ngach gui mail, tao khach hang.
                    ConnectionData.OpenMyConnection();
                    rdBus.tblRoleDetail_insert(rdDto);
                    ConnectionData.CloseMyConnection();
                }

                // Reset thong tin so luong da gui mail cua tat ca user trong group.
                UserLoginBUS ulBus = new UserLoginBUS();
                ConnectionData.OpenMyConnection();
                ulBus.tblUserLogin_UpdateByDepartmentId(departmentId, 0);
                ConnectionData.CloseMyConnection();
            }
            else
            {
                // Xóa phân quyền nâng cao.
                ConnectionData.OpenMyConnection();
                rdBus.tblRoleDetail_Delete(-1, departmentId);
                ConnectionData.CloseMyConnection();
            }

            PanelAdvanceSuccess.Visible = true;
            lblAdvanceSuccess.Text = "Cập nhập thành công !";

        }
        catch (Exception)
        {
            PanelAdvanceSuccess.Visible = false;
            PanelAdvance.Visible = true;
            lblAdvanceError.Text = "Kiểm tra lại dữ liệu nhập !";
        }
    }