示例#1
0
 private void buttonDangKy_Click(object sender, EventArgs e)
 {
     if (tbSEX.Text == "" || tbDC.Text == "" || tbID.Text == "" || tbMK.Text == "" || tbNV.Text == "" || tbTK.Text == "")
     {
         MessageBox.Show("Xin hãy điền đầy đủ thông tin!!!");
     }
     else
     {
         try
         {
             if (comboBoxLoaiTK.Text == "admin")
             {
                 //nv.themnvn(tbID.Text, tbTK.Text, tbMK.Text, tbLTK.Text, tbNV.Text, tbDC.Text, tbSEX.Text, ref err);
                 NhanVienBuiderDirectory buiderDirectory = new NhanVienBuiderDirectory();
                 AdminBuilder            adminBuilder    = new AdminBuilder();
                 controllerNhanVien      adminnhanvien   = buiderDirectory.Construct(adminBuilder, tbID.Text, tbTK.Text, tbMK.Text, tbNV.Text, tbDC.Text, tbSEX.Text);
                 if (nv.themnvn(adminnhanvien, ref err))
                 {
                     MessageBox.Show("Đã thêm xong rồi nè, hihi");
                 }
             }
             else if (comboBoxLoaiTK.Text == "thuthu")
             {
                 //nv.themnvn(tbID.Text, tbTK.Text, tbMK.Text, tbLTK.Text, tbNV.Text, tbDC.Text, tbSEX.Text, ref err);
                 NhanVienBuiderDirectory buiderDirectory = new NhanVienBuiderDirectory();
                 ThuThuBuilder           thuThuBuilder   = new ThuThuBuilder();
                 controllerNhanVien      thuthunhanvien  = buiderDirectory.Construct(thuThuBuilder, tbID.Text, tbTK.Text, tbMK.Text, tbNV.Text, tbDC.Text, tbSEX.Text);
                 if (nv.themnvn(thuthunhanvien, ref err))
                 {
                     MessageBox.Show("Đã thêm xong rồi nè, hihi");
                 }
             }
             else if (comboBoxLoaiTK.Text == "docgia")
             {
                 //nv.themnvn(tbID.Text, tbTK.Text, tbMK.Text, tbLTK.Text, tbNV.Text, tbDC.Text, tbSEX.Text, ref err);
                 NhanVienBuiderDirectory buiderDirectory = new NhanVienBuiderDirectory();
                 DocGiaBuilder           docGiaBuilder   = new DocGiaBuilder();
                 controllerNhanVien      docgianhanvien  = buiderDirectory.Construct(docGiaBuilder, tbID.Text, tbTK.Text, tbMK.Text, tbNV.Text, tbDC.Text, tbSEX.Text);
                 if (nv.themnvn(docgianhanvien, ref err))
                 {
                     MessageBox.Show("Đã thêm xong rồi nè, hihi");
                 }
             }
         }
         catch (SqlException)
         {
             MessageBox.Show("Bị lỗi khi thêm rồi !!!");
         }
     }
 }
示例#2
0
        //public bool themnvn(string manv, string tk, string mk, string loai,string tennv,string diachi,string sex, ref string err)
        //{
        //    string ktnv = @"exec dbo.kiemtranv N'" + manv + "'";
        //    string themnv = @"exec dbo.themnv N'" + manv + "',N'" + tk + "',N'" +mk + "',N'" + loai + "',N'" + tennv + "',N'" + diachi + "',N'" + sex + "'";
        //    DataTable dt = db.ExecuteQueryDataTable(ktnv, CommandType.Text);
        //    if (dt.Rows.Count == 0)
        //    {
        //        return db.MyExecuteNonQuery(themnv, CommandType.Text, ref err);
        //    }
        //    else return false;
        //}
        public bool themnvn(controllerNhanVien ctnhanvien, ref string err)
        {
            string    ktnv   = @"exec dbo.kiemtranv N'" + ctnhanvien.MaNhanVien + "'";
            string    themnv = @"exec dbo.themnv N'" + ctnhanvien.MaNhanVien + "',N'" + ctnhanvien.TaiKhoan + "',N'" + ctnhanvien.MatKhau + "',N'" + ctnhanvien.Loai + "',N'" + ctnhanvien.TenNhanVien + "',N'" + ctnhanvien.DiaChi + "',N'" + ctnhanvien.GioiTinh + "'";
            DataTable dt     = db.ExecuteQueryDataTable(ktnv, CommandType.Text);

            if (dt.Rows.Count > 0)
            {
                MessageBox.Show("Da co ID nay roi", " Da Ton Tai");
                return(false);
            }
            else
            {
                return(db.MyExecuteNonQuery(themnv, CommandType.Text, ref err));
            }
        }