Exemple #1
0
        public void SuaDichVu_2()
        {
            DAL.DataProvider.InitalizeConnection();


            DichVuDTO p = DichVuBUS.LayThongTinDichVu(DichVuBUS.PhatSinhMaDichVu() - 1);

            p.TenDV = "abc";
            p.DonVi = "Tô";

            DichVuBUS.CapNhatThongTinDichVu(p);


            DichVuDTO pNew = DichVuBUS.LayThongTinDichVu(p.MaDV);

            Assert.IsTrue(pNew.TenDV == p.TenDV);
        }
Exemple #2
0
        private void wbntSuadichvu_ButtonClick(object sender, DevExpress.XtraBars.Docking2010.ButtonEventArgs e)
        {
            switch (e.Button.Properties.Tag.ToString())
            {
            case "Lưu":
                //Kiểm tra thông tin hợp lệ
                if (txtTenDV.Text == "")
                {
                    return;
                }

                if (txtDonVi.Text == "")
                {
                    return;
                }

                //Lưu thông tin

                if (DichVuBUS.CapNhatThongTinDichVu(new DichVuDTO(Convert.ToInt32(txtMaDV.Text), txtTenDV.Text, Convert.ToDouble(txtDonGia.EditValue), txtDonVi.Text, (pictureEdit1.Image), listLoaiDichVu[cmbLoaiDV.SelectedIndex].MaLoaiDV)))
                {
                    //Thông báo thành công

                    XtraMessageBox.Show("Cập nhật dịch vụ thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    actionBack();
                }
                else
                {
                    //Thông báo thất bại

                    XtraMessageBox.Show("Cập nhật dịch vụ thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;

            case "Hủy":
                if (ThongBaoHuyKoLuuDichVu())
                {
                    actionBack();
                }
                break;

            default:
                break;
            }
        }
Exemple #3
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (this.state == 0)
            {
                //Cap nhat
                if (string.IsNullOrWhiteSpace(txtIdPhong.Text) ||
                    string.IsNullOrWhiteSpace(txtTenPhong.Text) ||
                    string.IsNullOrWhiteSpace(cbbTrangThai.Text) ||
                    string.IsNullOrWhiteSpace(txtDonGia.Text)
                    )
                {
                    MessageBox.Show("Vui lòng nhập đầy đủ thông tin của dịch vụ", "Lỗi thông tin",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (!txtDonGia.Text.All(char.IsDigit))
                    {
                        MessageBox.Show("Đơn giá phải là số", "Lỗi thông tin",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        DichVuDTO _data = new DichVuDTO();
                        _data.IdDichVu  = txtIdPhong.Text;
                        _data.TenDichVu = txtTenPhong.Text;
                        _data.TinhTrang = cbbTrangThai.Text;
                        _data.Gia       = Int32.Parse(txtDonGia.Text);


                        if (!dvBus.CapNhatThongTinDichVu(_data))
                        {
                            MessageBox.Show("Cập nhật thông tin dịch vụ vào cơ sở dữ liệu thất bại", "Thất bại",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            DocDuLieu(dvBus.LayDuDieu());
                            MessageBox.Show("Thông tin dịch vụ đã được cập nhật vào cơ sở dữ liệu", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            else
            if (this.state == 1)
            {
                //Them
                if (string.IsNullOrWhiteSpace(txtIdPhong.Text) ||
                    string.IsNullOrWhiteSpace(txtTenPhong.Text) ||
                    string.IsNullOrWhiteSpace(cbbTrangThai.Text) ||
                    string.IsNullOrWhiteSpace(txtDonGia.Text)
                    )
                {
                    MessageBox.Show("Vui lòng nhập đầy đủ thông tin của dịch vụ", "Lỗi thông tin",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (!txtDonGia.Text.All(char.IsDigit))
                    {
                        MessageBox.Show("Đơn giá phải là số", "Lỗi thông tin",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        DichVuDTO _data = new DichVuDTO();
                        _data.IdDichVu  = txtIdPhong.Text;
                        _data.TenDichVu = txtTenPhong.Text;

                        _data.TinhTrang = cbbTrangThai.Text;
                        _data.Gia       = Int32.Parse(txtDonGia.Text);


                        if (!dvBus.ThemThongTinDivhVu(_data))
                        {
                            MessageBox.Show("Thêm thông tin dịch vụ vào cơ sở dữ liệu thất bại hoặc ID Phòng bị trùng", "Thất bại",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            DocDuLieu(dvBus.LayDuDieu());
                            MessageBox.Show("Thông tin dịch vụ đã được thêm vào cơ sở dữ liệu", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            btnNhapLai_Click(sender, e);
        }