public string gioitinh; //Khai báo biến chuỗi để chuyển đỗi giữa kiểu true thành nam

        //Bắt đầu các lệnh truy vấn

        //Thêm khách hàng
        private void btnThemKH_Click(object sender, EventArgs e) // Khi nhấn nút thêm khách hàng
        {
            string tenkh  = txtTenKH.Text;
            string diachi = txtDiaChi.Text;
            string sdt    = txtSoDT.Text;
            string email  = txtEmail.Text;

            if (cbGioiTinh.Text == "Nam")
            {
                gioitinh = "True";
            }
            else if (cbGioiTinh.Text == "Nữ")
            {
                gioitinh = "False";
            }
            else if (cbGioiTinh.Text == "")
            {
                gioitinh = "";
            }
            string command = "";

            if (checkmail == true)    //Kiểm tra hợp lệ Email
            {
                if (sdt.Length <= 12) //Kiểm tra số lượng kí tự nhập vào ô số điện thoại
                {
                    command = connectdata.excutedata("Insert into tbl_KhachHang (TENKH,GIOITINH,DIACHI,SDT,EMAIL) values (N'" + tenkh + "','" + gioitinh + "',N'" + diachi + "','" + sdt + "','" + email + "')");
                    if (command == "OK")
                    {
                        MessageBox.Show("Dữ liệu đã được thêm thành công !", "Thêm dữ liệu thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtTenKH.Focus();
                        txtTenKH.Text   = "";
                        cbGioiTinh.Text = "";
                        txtDiaChi.Text  = "";
                        txtSoDT.Text    = "";
                        txtEmail.Text   = "";
                        loaddlKH();
                        dobanghetKH();
                    }
                    else
                    {
                        MessageBox.Show("Dữ liệu đã không được thêm thành công !", "Lỗi thêm dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Số điện quá dài, vui lòng chỉnh sửa", "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Email của bạn vừa nhập không hợp lệ", "Email sai", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (txtpass1.Text == txtpass2.Text)
     {
         if (txtpass1.Text.Length >= 6)
         {
             string trangthai = "";
             trangthai = webservices.excutedata("update tbl_NhanVien set PASSWORDS = '" + txtpass2.Text + "', CHANGPAS = '******' where MANV = '" + manv + "'");
             if (trangthai == "OK")
             {
                 MessageBox.Show("OK");
                 frm_login frm = new frm_login();
                 frm.Activate();
                 frm.Show();
                 this.Hide();
             }
             else
             {
                 MessageBox.Show("Lỗi");
             }
         }
         else
         {
             MessageBox.Show("lớn hơn 6 ký tự");
         }
     }
     else
     {
         MessageBox.Show("Hai mật khẩu không khớp.");
     }
 }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            string tinhtrang  = "";
            string tinhtrang2 = "";
            string mahd       = lblMaHD.Text;

            tinhtrang  = sevice_data.excutedata("update tbl_HoaDon set HideHD = 'true' where MAHD ='" + mahd + "'");
            tinhtrang2 = sevice_data.excutedata("update tbl_CTHD set HideCTHD = 'true' where MAHDONs ='" + mahd + "'");
            if (tinhtrang == "OK" && tinhtrang2 == "OK")
            {
                MessageBox.Show("Đã xóa hóa đơn thành công", "xóa thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                getData_HD();
            }
            else
            {
                MessageBox.Show("Có lỗi xảy ra !", "xóa lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
 //Xóa dữ liệu  #############################################################
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (lsvKH.SelectedItems.Count == 1)
     {
         string command   = "update tbl_KhachHang set HideKH = 'true' where MAKH = '" + txtMaKH.Text + "'";
         string tinhtrang = "";
         tinhtrang = webservice.excutedata(command);
         if (tinhtrang == "OK")
         {
             MessageBox.Show("Đã xóa khách hàng " + txtTenKH.Text + "", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             laydulieu();
             loaddata();
         }
         else
         {
             MessageBox.Show("Dữ liệu chưa được xóa", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Vui lòng chọn một hàng để thực hiện", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 5
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            string tennv   = txtTenNV.Text;
            string namsinh = datetime.Text;
            string email   = txtEmail.Text;
            string matkhau = txtMatKhau.Text;

            bochuyendoi();

            string cmd       = "insert into tbl_NhanVien (TENNV,GIOITINH,NAMSINH,EMAIL,PASSWORDS,QH,CHANGPAS) values (N'" + tennv + "','" + gt + "','" + namsinh + "','" + email + "','" + matkhau + "','" + quyenhan + "','" + changepass + "')";
            string trangthai = "";

            trangthai = webservices.excutedata(cmd);
            if (trangthai == "OK")
            {
                MessageBox.Show("Đã thêm nhân viên tên " + tennv + "", "Thêm thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                laydulieu();
                loaddata();
            }
            else
            {
                MessageBox.Show("Có lỗi khi thêm nhân viên " + tennv + "", "Thêm lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
 //Xóa sản phẩm $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 private void btnXoaSP_Click(object sender, EventArgs e)
 {
     if (lsvSP.SelectedItems.Count == 1)
     {
         string command   = "update tbl_SanPham set HideSP = 'True' where MASANPHAM = '" + txtMaSP.Text + "'";
         string tinhtrang = "";
         tinhtrang = webservice.excutedata(command);
         if (tinhtrang == "OK")
         {
             laydulieusanpham();
             loaddataproduc();
             MessageBox.Show("Đã bỏ xóa thành công sản phẩm mã " + txtTenSP.Text + "", "Bỏ xóa thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show("Có lỗi khi bỏ xóa sản phẩm mã " + txtTenSP.Text + ", Vui lòng kiểm tra lại", "Bỏ xóa lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Vui lòng chọn một sản phẩm", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }