Пример #1
0
        private void btThemKH_Click_1(object sender, EventArgs e)
        {
            if (txtMaKH.Text != "")
            {
                try
                {
                    string MaKH      = txtMaKH.Text.Trim();
                    string HotenKH   = txtTenKH.Text.Trim();
                    string Diachi    = txtDiaChi.Text.Trim();
                    string Dienthoai = txtSdt.Text.Trim();
                    string Email     = txtEmail.Text.Trim();


                    emp.Insert(MaKH, HotenKH, Diachi, Dienthoai, Email);
                    LoadKhachHang();
                    MessageBox.Show("Da them thanh cong");
                }
                catch (SqlException ex)
                {
                    MessageBox.Show("Loi!" + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Nhập mã khách hàng");
            }
        }
Пример #2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            int i = -1; string s = "";

            if (radioBtnKH.Checked)
            {
                try
                {
                    KhachHang ob = new KhachHang(txtMa.Text, txtTen.Text, txtDC.Text, txtDT.Text, txtEmail.Text);
                    i = kh.Insert(ob);
                }
                catch { s = "Dữ liệu đã nhập không phù hợp!\n Mời nhập lại!!"; }
            }
            else if (radioBtnNCC.Checked)
            {
                try
                {
                    NhaCC ob = new NhaCC(txtMa.Text, txtTen.Text, txtDC.Text, txtDT.Text, txtEmail.Text);
                    i = ncc.Insert(ob);
                }
                catch { s = "Dữ liệu đã nhập không phù hợp!\n Mời nhập lại!!"; }
            }
            switch (i)
            {
            case -2:
                s = "Lỗi kết nối!!";
                break;

            case 1:
                s = "Thêm thành công!!";
                btnLoad_Click(sender, e);
                break;

            case 2:
                s = "Không thể thêm dữ liệu!!\n Mã đối tác này đã tồn tại!!";
                break;

            case 0:
                s = "Lỗi!! Không thể thêm dữ liệu!!";
                break;
            }
            MessageBox.Show(s, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Пример #3
0
        private void bt_ToDichVu_Click(object sender, EventArgs e)
        {
            if (datetime_NgayNhanPhong.Value.ToString() == "")
            {
                MessageBox.Show("Chưa chọn ngày nhận phòng", "Erro");
                return;
            }
            if (date_NgayDi.Value.ToString() == "")
            {
                MessageBox.Show("Chưa chọn ngày đi", "Erro");
                return;
            }
            if (DropDown_LoaiPhong.selectedIndex == -1)
            {
                MessageBox.Show("Chưa chọn loại phòng", "Erro");
                return;
            }
            if (DropDown_Phong.selectedIndex == -1)
            {
                MessageBox.Show("Chưa chọn phòng", "Erro");
                return;
            }
            if (txb_TenKhach.Text == "")
            {
                MessageBox.Show("Chưa nhập tên khách hàng", "Erro");
                return;
            }
            if (date_SinhNhat.Value.ToString() == "")
            {
                MessageBox.Show("Chưa chọn ngày sinh", "Erro");
                return;
            }
            if (txb_CMND.Text == "")
            {
                MessageBox.Show("Chưa nhập CMND", "Erro");
                return;
            }
            if (DropDown_GioiTinh.selectedIndex == -1)
            {
                MessageBox.Show("Chưa chọn giới tính", "Erro");
                return;
            }
            if (txb_SDT.Text == "")
            {
                MessageBox.Show("Chưa nhập số điện thoại", "Erro");
                return;
            }
            panel_ListDV.Controls.Clear();
            //ThemKH
            if (kt_DatPhong == false)
            {
                page_DatPhong.SetPage(1);
                DTO_CTHD      obj_cthd = new DTO_CTHD();
                DTO_KhachHang obj_kh   = new DTO_KhachHang();
                obj_kh.Makh     = txb_MaKH.Text;
                obj_kh.Tenkh    = txb_TenKhach.Text;
                obj_kh.Cmnd     = txb_CMND.Text;
                obj_kh.Gioitinh = DropDown_GioiTinh.selectedValue;
                obj_kh.Ngaysinh = date_SinhNhat.Value.ToString();
                obj_kh.Sdt      = txb_SDT.Text;
                obj_kh.Quoctich = txb_QuocTich.Text;
                obj_kh.Diachi   = txb_DiaChi.Text;
                if (bus_kh.Insert(obj_kh) != "0")
                {
                    MessageBox.Show("Thêm khách hàng thất bại");
                }
                //Them cthd
                obj_cthd.Macthd        = bus_cthd.TaoMaCTHD();
                get_MaCTHD             = obj_cthd.Macthd;
                obj_cthd.Makh          = txb_MaKH.Text;
                obj_cthd.Ngaynhanphong = date_NgayNhan.Value.ToString();
                obj_cthd.Ngaydi        = date_NgayDi.Value.ToString();
                obj_cthd.Sophong       = DropDown_Phong.selectedValue;
                obj_cthd.Tratruoc      = "0";
                obj_cthd.Manv          = Message;
                if (bus_cthd.Insert(obj_cthd) != "0")
                {
                    MessageBox.Show("Chọn phòng thất bại");
                }
                LoadDichVu();
                txbDV_MaKH.Text = obj_kh.Makh;
                txbTT_MaKH.Text = obj_kh.Makh;
                //Update tinh trang phong

                List <DTO_LoaiPhong> lsobj_lp = new List <DTO_LoaiPhong>();
                List <DTO_Phong>     lsobj_p  = new List <DTO_Phong>();

                string result  = bus_p.SelectAll(lsobj_p);
                string result1 = bus_lp.SelectAll(lsobj_lp);

                var Malp = from x in lsobj_p
                           join y in lsobj_lp on x.Malp equals y.Malp
                           where x.Sophong == obj_cthd.Sophong
                           select new
                {
                    SoPhong   = x.Sophong,
                    TrangThai = "USED",
                    MaLP      = x.Malp,
                };


                foreach (var x in Malp)
                {
                    objp.Sophong = x.SoPhong;
                    objp.Malp    = x.MaLP;
                    objp.Status  = x.TrangThai;
                }
                bus_p.Update(objp);
            }
        }