Example #1
0
 protected void btnDoi_Click(object sender, EventArgs e)
 {
     if (KTrong(txtMKcu.Text, txtMKM.Text, txtXN.Text))
     {
         if (KTTK(txtTK.Text, txtMKcu.Text) == false)
         {
             if (txtMKM.Text == txtXN.Text)
             {
                 tbl_Account ac = db.tbl_Accounts.SingleOrDefault(c => c.Account == txtTK.Text);
                 // ac.Account = txtTK.Text;
                 ac.Password = txtMKM.Text;
                 db.SubmitChanges();
                 Label1.Text = "Thay đổi thành công.";
             }
             else
             {
                 Label1.Text = "Hai mật khẩu khác nhau.";
             }
         }
         else
         {
             Label1.Text = "Mật khẩu không đúng";
         }
     }
     else
     {
         Label1.Text = "Bạn chưa nhập đủ thông tin.";
     }
 }
Example #2
0
        public ActionResult AddAccount(tbl_Account model)
        {
            if (ModelState.IsValid)
            {
                tbl_Account obj = new tbl_Account();
                obj.RefNo         = model.RefNo;
                obj.AccountNumber = model.AccountNumber;
                obj.AccountHolder = model.AccountHolder;
                obj.CurrentBalace = model.CurrentBalace;
                obj.BankName      = model.BankName;
                obj.OpeningDate   = model.OpeningDate;
                obj.IsActive      = model.IsActive;

                if (model.RefNo == 0)
                {
                    dbObj.tbl_Account.Add(obj);
                    this.AddNotification("Account is Added Successfully", NotificationType.SUCCESS);
                    dbObj.SaveChanges();
                }
                else
                {
                    dbObj.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                    dbObj.SaveChanges();
                }
            }

            ModelState.Clear();
            return(View("Account"));
        }
Example #3
0
 protected void btnthem_Click(object sender, EventArgs e)
 {
     if (KiemTra(txtTaikhoan.Text))
     {
         if (Kiemtrarong(txtTaikhoan.Text, txtPass.Text) == true)
         {
             tbl_Account a = new tbl_Account();
             a.Account  = txtTaikhoan.Text;
             a.Password = txtPass.Text;
             a.Power    = DropDownList1.Text;
             db.tbl_Accounts.InsertOnSubmit(a);
             db.SubmitChanges();
             load();
             Label1.Text = "Thêm thành công";
             Label3.Text = "";
             rong();
         }
         else
         {
             Label1.Text = "Chưa nhập tài khoản hoặc mật khẩu.";
             Label3.Text = "";
         }
     }
     else
     {
         Label3.Text = "Tài khoản này đã tồn tại.";
         txtTaikhoan.Focus();
     }
 }
        //Delete users
        public JsonResult DelUsers(int id, int?pageNumber)
        {
            tbl_Account tbl_Account = db.tbl_Account.Find(id);

            db.tbl_Account.Remove(tbl_Account);
            db.SaveChanges();

            //list all users
            var showlst = db.tbl_Account.
                          Join(db.Branches,
                               a => a.Branch, b => b.Id,
                               (a, b) => new UserProfileView
            {
                AID      = a.AID,
                Username = a.Username,
                Password = a.Password,
                FName    = a.FName,
                LName    = a.LName,
                CDate    = a.CDate,
                Branch   = b.Id,
                Role     = a.Role
            }).ToList();

            return(Json(showlst, JsonRequestBehavior.AllowGet));
        }
        public JsonResult AddNewUser(string username, string password, string FName, string LName, string Role, int Branch, int?pageNumber)
        {
            tbl_Account tbluser = new tbl_Account();

            tbluser.Username = username;
            tbluser.Password = password;
            tbluser.FName    = FName;
            tbluser.LName    = LName;
            tbluser.Role     = Role;
            tbluser.Branch   = Branch;
            tbluser.CDate    = DateTime.Now;
            db.tbl_Account.Add(tbluser);
            db.SaveChanges();

            //joing two tables tbl_Account and Branche, then using the result to fill the ViewModel UserProfileView
            var getlst = db.tbl_Account.
                         Join(db.Branches,
                              a => a.Branch, b => b.Id,
                              (a, b) => new UserProfileView
            {
                AID      = a.AID,
                Username = a.Username,
                Password = a.Password,
                FName    = a.FName,
                LName    = a.LName,
                CDate    = a.CDate,
                Branch   = b.Id,
                Role     = a.Role
            }).ToList().ToPagedList(pageNumber ?? 1, 3);

            // var getlst = db.tbl_Account.Select(x => new { AID = x.AID, Username = x.Username, Password = x.Password, FName = x.FName, LName = x.LName, Role = x.Role, CDate = x.CDate, Branch = x.Branch });
            return(Json(getlst, JsonRequestBehavior.AllowGet));
        }
        public ActionResult DangNhap(FormCollection collection)
        {
            var         taikhoan = collection["userName"];
            var         matKhau  = collection["password"];
            tbl_Account ad       = ddd.tbl_Accounts.FirstOrDefault(us => us.UserName == taikhoan && us.Password == matKhau);

            if (string.IsNullOrEmpty(taikhoan))
            {
                ViewData["Loi1"] = "Tên đăng nhập không được để trống!";
            }
            else if (string.IsNullOrEmpty(matKhau))
            {
                ViewData["Loi2"] = "Mật khẩu không được để trống!";
            }
            else if (ad != null)
            {
                Session["PQ"]           = ad.tbl_TypeOfAccount.Id;
                Session["CV"]           = ad.tbl_TypeOfAccount.TypeName;
                Session["ten"]          = ad.tbl_User.UserName;
                Session["anh"]          = ad.AccountImage;
                Session["TinhTrangHD"]  = ad.Status;
                Session["AdminIsLogin"] = true;
                ViewBag.Thongbao        = "Chúc mừng đăng nhập thành công";
                return(RedirectToAction("Admin", "Admin"));
            }
            else
            {
                ViewData["Loi"] = "Tên đăng nhập hoặc mật khẩu không chính xác!";
            }
            return(View());
        }
Example #7
0
 public void LoadUser(tbl_Account acc = null)
 {
     if (acc != null)
     {
         ddlUser.Items.Clear();
         ddlUser.Items.Insert(0, new ListItem(acc.Username, acc.ID.ToString()));
     }
     else
     {
         var CreateBy = AccountController.GetAllByRoleID(2);
         ddlUser.Items.Clear();
         ddlUser.Items.Insert(0, new ListItem("Nhân viên phụ trách", ""));
         // drop down list at update register modal
         ddlUserModal.Items.Clear();
         ddlUserModal.Items.Insert(0, new ListItem("Chọn nhân viên", "0"));
         ddlUserCreateModal.Items.Insert(0, new ListItem("Chọn nhân viên", "0"));
         if (CreateBy.Count > 0)
         {
             foreach (var p in CreateBy)
             {
                 if (p.Username != "hotline")
                 {
                     ListItem listitem = new ListItem(p.Username, p.ID.ToString());
                     ddlUser.Items.Add(listitem);
                     ddlUserModal.Items.Add(listitem);
                     ddlUserCreateModal.Items.Add(listitem);
                 }
             }
             ddlUser.DataBind();
             ddlUserModal.DataBind();
         }
     }
 }
        public static Accounts TblToData(tbl_Account tblaccounts)
        {
            try
            {
                if (tblaccounts == null) return null;

                Accounts account = new Accounts();

                account.AccountID = tblaccounts.AccountID;
                account.FBUID = tblaccounts.FBUID ?? 0;
                account.FirstName = tblaccounts.FirstName;
                account.LastName = tblaccounts.LastName;
                account.EmailVerified = tblaccounts.EmailVerified ?? false;
                account.Username = tblaccounts.Username;
                account.Password = tblaccounts.Password;
                account.Salt = tblaccounts.Salt;
                account.AccessToken = tblaccounts.AccessToken;
                account.Email = tblaccounts.Email;
                account.Address = tblaccounts.Address;
                account.BirthDate = tblaccounts.BirthDate ?? DateTime.Now;
                account.ProfilePicture = tblaccounts.ProfilePicture;
                account.ConfirmationCode = tblaccounts.ConfirmationCode;
                account.CreateDate = tblaccounts.CreateDate ?? DateTime.Now;

                return account;
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Example #9
0
        public static string deleteDeliverySession(tbl_Account acc, List <DeliverySession> deliverySession, string page = "danh-sach-van-chuyen")
        {
            using (var con = new inventorymanagementEntities())
            {
                var session = con.Sessions
                              .Where(x => x.AccountID == acc.ID)
                              .Where(x => x.Page.ToLower() == page.ToLower())
                              .FirstOrDefault();

                if (session != null)
                {
                    var oldDdeliveries = JsonConvert.DeserializeObject <List <DeliverySession> >(session.Value);

                    oldDdeliveries = oldDdeliveries
                                     .Except(
                        oldDdeliveries.Join(
                            deliverySession,
                            olds => olds.OrderID,
                            news => news.OrderID,
                            (olds, news) => olds
                            )
                        )
                                     .OrderByDescending(o => o.OrderID)
                                     .ToList();
                    session.Value        = JsonConvert.SerializeObject(oldDdeliveries);
                    session.ModifiedDate = DateTime.Now;

                    con.SaveChanges();

                    return(session.Value);
                }

                return(JsonConvert.SerializeObject(new List <DeliverySession>()));
            }
        }
Example #10
0
 public ActionResult SaveForm(string keyValue, tbl_Account account)
 {
     try
     {
         if (keyValue != "")
         {
             //account.AccountId = keyValue;
             var model = tbl_Account.SingleOrDefault("where accountId=@0", keyValue);
             if (model != null)
             {
                 model = EntityConvertTools.CopyToModel <tbl_Account, tbl_Account>(account, model);
                 model.Update();
             }
         }
         else
         {
             //新增
         }
         return(Success("保存成功"));
     }
     catch (Exception ex)
     {
         ex.Data["Method"] = "AccountController>>Register";
         new ExceptionHelper().LogException(ex);
         return(Error("保存失败"));
     }
 }
Example #11
0
        public static bool Create(tbl_Order order, int bankID, tbl_Account user)
        {
            using (var con = new inventorymanagementEntities())
            {
                var cusBankID = con.Banks.Where(x => x.ID == bankID).FirstOrDefault();
                var accBankID = con.BankAccounts.Where(x => x.BankID == bankID).FirstOrDefault();

                if (cusBankID != null && accBankID != null)
                {
                    var now      = DateTime.Now;
                    var nullDate = new DateTime(1970, 1, 1, 0, 0, 0);
                    var transfer = new BankTransfer();
                    transfer.UUID         = Guid.NewGuid();
                    transfer.OrderID      = order.ID;
                    transfer.CusBankID    = cusBankID.ID;
                    transfer.AccBankID    = accBankID.ID;
                    transfer.DoneAt       = nullDate;
                    transfer.Money        = 0;
                    transfer.Status       = 2; // Chưa nhận tiền
                    transfer.CreatedBy    = user.ID;
                    transfer.CreatedDate  = now;
                    transfer.ModifiedBy   = user.ID;
                    transfer.ModifiedDate = now;

                    con.BankTransfers.Add(transfer);
                    con.SaveChanges();
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Example #12
0
        /// <summary>
        /// Cập nhật thư viện hình ảnh sản phẩm
        /// </summary>
        /// <param name="productID"></param>
        private void _updateImageGallery(int productID, tbl_Account acc)
        {
            // Delete Image
            if (!String.IsNullOrEmpty(hdfDeleteImageGallery.Value))
            {
                var imageIDList = hdfDeleteImageGallery.Value
                                  .Split(',')
                                  .Where(x => !String.IsNullOrEmpty(x))
                                  .ToList();

                foreach (var strID in imageIDList)
                {
                    ProductImageController.Delete(Convert.ToInt32(strID));
                }
            }
            // Add Image
            if (uploadImageGallery.HasFiles)
            {
                foreach (HttpPostedFile httpPostedFile in uploadImageGallery.PostedFiles)
                {
                    var fileName = _uploadImage(productID, httpPostedFile);
                    ProductImageController.Insert(productID, fileName, false, DateTime.Now, acc.Username);
                }
            }
        }
Example #13
0
        public ActionResult Deletee(int id)
        {
            tbl_Account tbl_Account = db.tbl_Account.Find(id);

            db.tbl_Account.Remove(tbl_Account);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "AID,Username,Password,FName,LName,CDate,Branch")] tbl_Account tbl_Account)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_Account).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_Account));
 }
Example #15
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Label       lbTK = (Label)GridView1.Rows[e.RowIndex].FindControl("lbTK");
            tbl_Account a    = db.tbl_Accounts.SingleOrDefault(c => c.Account == lbTK.Text);

            db.tbl_Accounts.DeleteOnSubmit(a);
            db.SubmitChanges();
            load();
            txtTaikhoan.Focus();
            Label1.Text = "";
        }
Example #16
0
 public async Task <ActionResult <tbl_Account> > Post(tbl_Account model)
 {
     try
     {
         return(await repository.Add(model));
     }
     catch (Exception)
     {
         return(NoContent());
     }
 }
Example #17
0
 public ActionResult Edit([Bind(Include = "ID_Account,Account_Name,Sex,Birthday,Address,Email,Phone,ID_Position,Account,Pass,CreateBy,UpdateBy,CreateDate,UpdateDate,Status,Avarta")] tbl_Account tbl_Account)
 {
     if (ModelState.IsValid)
     {
         tbl_Account.UpdateDate      = DateTime.Now;
         db.Entry(tbl_Account).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ID_Position = new SelectList(db.tbl_Position, "ID_Position", "Position_Name", tbl_Account.ID_Position);
     return(View(tbl_Account));
 }
Example #18
0
 public ActionResult EditAccount([Bind(Include = "UserId,UserName,Password,RememberMe,Email,PasswordEmail,IsAdmin")] tbl_Account tbl_Account)
 {
     if (ModelState.IsValid)
     {
         tbl_Account.Password        = Common.CommonHelper.Encrypt(tbl_Account.Password, true);
         tbl_Account.PasswordEmail   = Common.CommonHelper.Encrypt(tbl_Account.PasswordEmail, true);
         tbl_Account.IsAdmin         = true;
         db.Entry(tbl_Account).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tbl_Account));
 }
Example #19
0
        public static void updateDelivery(tbl_Account acc, List <DeliverySession> session)
        {
            using (var con = new inventorymanagementEntities())
            {
                var now = DateTime.Now;

                foreach (var item in session)
                {
                    var data = con.Deliveries
                               .Where(x => x.OrderID == item.OrderID)
                               .FirstOrDefault();

                    if (data != null)
                    {
                        data.ShipperID    = item.ShipperID;
                        data.Times        = item.DeliveryTimes;
                        data.Status       = item.DeliveryStatus;
                        data.COD          = Convert.ToDecimal(item.ShippingFee);
                        data.COO          = Convert.ToDecimal(item.COD);
                        data.ModifiedBy   = acc.ID;
                        data.ModifiedDate = now;

                        con.SaveChanges();
                    }
                    else
                    {
                        var delivery = new Delivery()
                        {
                            UUID         = Guid.NewGuid(),
                            OrderID      = item.OrderID,
                            ShipperID    = item.ShipperID,
                            Status       = item.DeliveryStatus,
                            Image        = String.Empty,
                            COD          = Convert.ToDecimal(item.ShippingFee),
                            COO          = Convert.ToDecimal(item.COD),
                            ShipNote     = String.Empty,
                            StartAt      = now,
                            Note         = String.Empty,
                            CreatedBy    = acc.ID,
                            CreatedDate  = now,
                            ModifiedBy   = acc.ID,
                            ModifiedDate = now,
                            Times        = item.DeliveryTimes
                        };

                        con.Deliveries.Add(delivery);
                        con.SaveChanges();
                    }
                }
            }
        }
Example #20
0
        // GET: Admin/tbl_Accounts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_Account tbl_Account = db.tbl_Account.Find(id);

            if (tbl_Account == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_Account));
        }
Example #21
0
 public static tbl_Account GetByID(int ID)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_Account acc = dbe.tbl_Account.Where(a => a.ID == ID).FirstOrDefault();
         if (acc != null)
         {
             return(acc);
         }
         else
         {
             return(null);
         }
     }
 }
Example #22
0
        public static void deleteRegisterProductSession(tbl_Account acc, string page = "danh-sach-nhap-hang")
        {
            using (var con = new inventorymanagementEntities())
            {
                var session = con.Sessions
                              .Where(x => x.AccountID == acc.ID)
                              .Where(x => x.Page.ToLower() == page.ToLower());

                if (session.Count() > 0)
                {
                    con.Sessions.RemoveRange(session);
                    con.SaveChanges();
                }
            }
        }
Example #23
0
 public static tbl_Account GetByUsername(string Username)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_Account acc = dbe.tbl_Account.Where(a => a.Username == Username).FirstOrDefault();
         if (acc != null)
         {
             return(acc);
         }
         else
         {
             return(null);
         }
     }
 }
Example #24
0
 public static tbl_Account GetByEmail(string Email)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         tbl_Account acc = dbe.tbl_Account.Where(a => a.Email == Email).FirstOrDefault();
         if (acc != null)
         {
             return(acc);
         }
         else
         {
             return(null);
         }
     }
 }
Example #25
0
        // GET: Admin/tbl_Accounts/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_Account tbl_Account = db.tbl_Account.Find(id);

            if (tbl_Account == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ID_Position = new SelectList(db.tbl_Position, "ID_Position", "Position_Name", tbl_Account.ID_Position);
            return(View(tbl_Account));
        }
Example #26
0
 public void LoadStatus(tbl_Account acc = null)
 {
     if (acc != null)
     {
         ddlStatus.Items.Clear();
         ddlStatus.Items.Insert(0, new ListItem("Đang hiện", "1"));
     }
     else
     {
         ddlStatus.Items.Clear();
         ddlStatus.Items.Insert(0, new ListItem("Trạng thái", ""));
         ddlStatus.Items.Insert(1, new ListItem("Đang hiện", "1"));
         ddlStatus.Items.Insert(2, new ListItem("Đang ẩn", "0"));
     }
 }
        public void LoadCreatedBy(tbl_Account acc = null)
        {
            if (acc != null)
            {
                ddlCreatedBy.Items.Clear();
                ddlCreatedBy.Items.Insert(0, new ListItem(acc.Username, acc.Username));
            }
            else
            {
                var CreateBy = AccountController.GetAllNotSearch().Where(x => x.RoleID == 0 || x.RoleID == 2).ToList();
                ddlCreatedBy.Items.Clear();
                ddlCreatedBy.Items.Insert(0, new ListItem("Nhân viên tạo đơn", ""));
                if (CreateBy.Count > 0)
                {
                    foreach (var p in CreateBy)
                    {
                        ListItem listitem = new ListItem(p.Username, p.Username);
                        ddlCreatedBy.Items.Add(listitem);
                    }
                    ddlCreatedBy.DataBind();
                }

                // Add Customer Bank drop down list
                var cusBanks = BankController.getDropDownList();
                cusBanks[0].Text = "Ngân hàng chuyển";
                ddlCustomerBank.Items.Clear();
                ddlCustomerBank.Items.AddRange(cusBanks.ToArray());
                ddlCustomerBank.DataBind();

                // Add Account Bank drop down list
                var accBanks = BankAccountController.getDropDownList();
                accBanks[0].Text = "Ngân hàng nhận";
                ddlBankReceive.Items.Clear();
                ddlBankReceive.Items.AddRange(accBanks.ToArray());
                ddlBankReceive.DataBind();

                ddlAccoutBank.Items.Clear();
                ddlAccoutBank.Items.AddRange(accBanks.ToArray());
                ddlAccoutBank.DataBind();

                // Add Order status
                ddlStatus.Items.Clear();
                ddlStatus.Items.Add(new ListItem("Trạng thái giao dịch", "0"));
                ddlStatus.Items.Add(new ListItem("Đã nhận tiền", "1"));
                ddlStatus.Items.Add(new ListItem("Chưa nhận tiền", "2"));
                ddlStatus.SelectedIndex = 0;
            }
        }
Example #28
0
        public ActionResult EditAccount(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_Account tbl_Account = db.tbl_Account.Find(id);

            if (tbl_Account == null)
            {
                return(HttpNotFound());
            }
            tbl_Account.Password      = null;
            tbl_Account.PasswordEmail = null;
            return(View(tbl_Account));
        }
Example #29
0
 public static tbl_Account LoginEmail(string Email, string Password)
 {
     using (var dbe = new inventorymanagementEntities())
     {
         Password = PJUtils.Encrypt("userpass", Password);
         tbl_Account acc = dbe.tbl_Account.Where(a => a.Email == Email && a.Password == Password).FirstOrDefault();
         if (acc != null)
         {
             return(acc);
         }
         else
         {
             return(null);
         }
     }
 }
Example #30
0
        public async Task <ActionResult <tbl_Account> > Put(int id, tbl_Account model)
        {
            if (id != model.Id)
            {
                return(BadRequest());
            }

            try
            {
                return(await repository.Update(model));
            }
            catch (DbUpdateConcurrencyException)
            {
                return(NoContent());
            }
        }
Example #31
0
        public static void updateDeliverySession(
            tbl_Account acc,
            List <DeliverySession> deliverySession,
            string page = "danh-sach-van-chuyen"
            )
        {
            using (var con = new inventorymanagementEntities())
            {
                var session = con.Sessions
                              .Where(x => x.AccountID == acc.ID)
                              .Where(x => x.Page.ToLower() == page.ToLower())
                              .FirstOrDefault();

                if (session != null)
                {
                    var oldDdeliveries = JsonConvert.DeserializeObject <List <DeliverySession> >(session.Value);
                    // update dữ liệu
                    oldDdeliveries = oldDdeliveries
                                     .GroupJoin(
                        deliverySession,
                        olds => olds.OrderID,
                        news => news.OrderID,
                        (olds, news) => new { olds, news }
                        )
                                     .SelectMany(
                        x => x.news.DefaultIfEmpty(),
                        (parent, child) =>
                    {
                        if (child != null)
                        {
                            return(child);
                        }
                        else
                        {
                            return(parent.olds);
                        }
                    }
                        )
                                     .ToList();

                    session.Value        = JsonConvert.SerializeObject(oldDdeliveries);
                    session.ModifiedDate = DateTime.Now;

                    con.SaveChanges();
                }
            }
        }
Example #32
0
        // Lưu Thông tin Nhân viên mới
        private void btn_LuuMoi_Click(object sender, EventArgs e)
        {
            tbl_HoSoNhanVien tbl = new tbl_HoSoNhanVien();

            tbl.SoCMND = lbl_NewCMND.Text.Trim();
            //MessageBox.Show("So CMND moi : " + tbl.SoCMND);
            if (txt_NewName.Text == "")
            {
                MessageBox.Show("Nhập Họ Tên ", "Thông báo");
                txt_Name.Focus();
                return;
            }
            else
            {
                tbl.TenNhanVien = txt_NewName.Text.ToUpper();
            }
            tbl.NgaySinh= dtpic_NewDate.Value;
            if ((!rdb_NewBoy.Checked) && (!rdb_NewGril.Checked))
            {
                MessageBox.Show("Chọn giới tính", "Thông báo");
                rdb_NewGril.Focus();
                return;
            }
            else
            {
                if (rdb_NewBoy.Checked)
                {
                    tbl.GioiTinh = true;
                }
                else
                {
                    tbl.GioiTinh = false;
                }
            }
            if (txt_NewAddress.Text == "") 
            {
                MessageBox.Show("Nhập Địa Chỉ", "Thông báo");
                txt_NewAddress.Focus();
                return;
            }
            else
            {
                tbl.DiaChi = txt_NewAddress.Text.ToUpper();
                
            }
            
            if (txt_NewFone.Text == "")
            {
                MessageBox.Show("Nhập số diện thoại", "Thông báo");
                txt_NewFone.Focus();
                return;
            }
            else
            {
                
                        tbl.SoDienThoai= txt_NewFone.Text;
                    
                
            }
            //Ch"ức vụ 
            if  (cmb_NewChucVu.SelectedIndex == -1)
            {
                MessageBox.Show("Chon Chức vụ ", "Thông Báo");
                cmb_NewChucVu.Focus();
                return;
            }
            else
            {      
                tbl.MaChucVu= MaCVNew;
                User_MCV = MaCVNew;
               
            }
           tbl.DaThanhToan=false;
           tbl.TienLuongThangTruoc = 0;

            tbl.NgayVaoLam = dtpic_NewIn.Value;
            //insert 
            //tbl.SoCMND = "201537486";
            //tbl.TenNhanVien ="Oanh";
            //tbl.GioiTinh = true;
            //tbl.DiaChi = txt_NewAddress.Text.ToUpper();
            //tbl.SoDienThoai = txt_NewFone.Text;
            //tbl.MaChucVu = MaCVNew;
            //tbl.DaThanhToan = false;
            //tbl.TienLuongThangTruoc = 0;

            //
           // MessageBox.Show("SO CMND MOI INSERT :" + tbl.SoCMND);
            bl_nhanvien.sp_insert_NhanVien(tbl);


             
            
            // tao tai khoan 

            tbl_Account tbl_ac = new tbl_Account();
            tbl_ac.User = UserName;
            tbl_ac.Pass = "******";
            tbl_ac.MaCV = User_MCV;
            tbl_ac.TT = false;
            bl_nhanvien.sp_insert_Account(tbl_ac); 
            MessageBox.Show("Thêm thành công");
            cmb_NewChucVu.SelectedIndex = -1;
            lbl_NewCMND.Text = "";
            txt_ID1.Text = "";
            settextboxnull();
            Hide_Control1();
            Load_DSNV();
           
        }