示例#1
0
        private void btnLogined_Click(object sender, EventArgs e)
        {
            if (txtAccount.Text.Trim().Equals("") || txtPass.Text.Trim().Equals(""))
            {
                MessageBox.Show("Nhập đầy đủ thông tin đăng nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                //WSC.CMServices s = new WSC.CMServices();
                //var date_server = s.getDateTime();
                //var dtime = DateTime.Parse(date_server);

                //if ((DateTime.Now - dtime).TotalMinutes >= 1)
                //    MessageBox.Show("Sai thông tin ngày giờ hệ thống, vui lòng cài đặt lại giờ hệ thống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //else
                //{
                cls.clsProcess       cls = new cls.clsProcess();
                CFManagerDataContext db  = new CFManagerDataContext(frmOpenConnection.connection);
                var l = from x in db.tAccounts
                        from y in db.tGroupUsers
                        from z in db.tBranches
                        where x.GroupUserId == y.Id && x.BranchId == z.Id && x.Status != 0 && x.Status != 2 && x.Username == txtAccount.Text.Trim() &&
                        x.Password == cls.Encrypt(txtPass.Text.Trim()) && x.BranchTypeId == int.Parse(branchType)
                        select new { x.Id, x.Username, x.FullName, x.GroupUserId, y.GroupCode, y.GroupName, x.BranchId, x.BranchTypeId, z.BranchName };
                if (l.Count() > 0)
                {
                    WindowsFormsApplication3.Form1.logined        = true;
                    WindowsFormsApplication3.Form1.user_acc       = l.FirstOrDefault().Username;
                    WindowsFormsApplication3.Form1.group_id       = l.FirstOrDefault().GroupUserId;
                    WindowsFormsApplication3.Form1.group_code     = l.FirstOrDefault().GroupCode;
                    WindowsFormsApplication3.Form1.name           = l.FirstOrDefault().FullName;
                    WindowsFormsApplication3.Form1.group_name     = l.FirstOrDefault().GroupName;
                    WindowsFormsApplication3.Form1.user_id        = l.FirstOrDefault().Id;
                    WindowsFormsApplication3.Form1.branch_type_id = l.FirstOrDefault().BranchTypeId;
                    WindowsFormsApplication3.Form1.branch_id      = l.FirstOrDefault().BranchId.Value;
                    WindowsFormsApplication3.Form1.branch_name    = l.FirstOrDefault().BranchName;
                    checkStockOutputInternal();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Thông tin đăng nhập không chính xác, vui lòng thử lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                //}
            }
        }
示例#2
0
 private void btnChange_Click(object sender, EventArgs e)
 {
     if (txtUser.Text.Trim().Equals("") ||
         txtPassOld.Text.Trim().Equals("") ||
         txtPassNew.Text.Trim().Equals("") ||
         txtPassNew2.Text.Trim().Equals(""))
     {
         MessageBox.Show("Vui lòng nhập đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         if (txtPassNew.Text.Trim().Equals(txtPassNew2.Text.Trim()))
         {
             if (txtPassNew.Text.Trim().Length >= 6 && txtPassNew2.Text.Trim().Length >= 6)
             {
                 CFManagerDataContext db = new CFManagerDataContext(frmOpenConnection.connection);
                 cls.clsProcess       cl = new cls.clsProcess();
                 var check = from x in db.tAccounts
                             where x.Username == txtUser.Text.Trim() &&
                             x.Password == cl.Encrypt(txtPassOld.Text.Trim()) &&
                             x.Status != 0 &&
                             x.BranchTypeId == WindowsFormsApplication3.Form1.branch_type_id
                             select x;
                 if (check.Count() == 1)
                 {
                     check.FirstOrDefault().Password = cl.Encrypt(txtPassNew.Text.Trim());
                     db.SubmitChanges();
                     MessageBox.Show("Thay đổi mật khẩu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("Thông tin tài khoản cũ không đúng, kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
             }
             else
             {
                 MessageBox.Show("Nhập mật khẩu từ 6 kí tự trở lên, kiểm tra lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             MessageBox.Show("Mật khẩu xác nhận không trùng khớp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
示例#3
0
        public bool insertAccount(string us, string pw, string name, string email, bool sex, string birth, string phone, string add, string stt, int group, string note, int branch, int branchtype, out string mess)
        {
            mess = "";
            bool       ok  = false;
            clsProcess cls = new clsProcess();

            try
            {
                var u = new tAccount();
                u.Username = us;
                u.FullName = name;
                u.Password = cls.Encrypt(pw);
                u.Email    = email;
                u.Sex      = sex;
                if (birth != "")
                {
                    u.Birthday = DateTime.Parse(birth);
                }
                u.Phone        = phone;
                u.Address      = add;
                u.Status       = byte.Parse(stt);
                u.GroupUserId  = group;
                u.Note         = note;
                u.CreateAt     = DateTime.Now;
                u.CreateBy     = WindowsFormsApplication3.Form1.user_id;
                u.BranchTypeId = branchtype;
                u.BranchId     = branch;
                db.tAccounts.InsertOnSubmit(u);
                db.SubmitChanges();
                ok = true;
            }
            catch (Exception ax)
            {
                ok   = false;
                mess = ax.Message;
            }
            return(ok);
        }