Exemplo n.º 1
0
        }//end default constructor

        public UIServiceGridView(UIServicesManagement parent) : this()
        {
            // Initialize BUS
            serviceBUS    = new ServiceBUS();
            this.ParentUI = parent;
            LoadData();
        }//end constructor
        private void frmQuanLiDichVu_Load(object sender, EventArgs e)
        {
            List <DichVuDTO> lstt = new List <DichVuDTO>();

            lstt = ServiceBUS.LoadDanhSach();
            for (int i = 0; i < lstt.Count; i++)
            {
                lstt[i].DonGia = Convert.ToDecimal(string.Format("{0:0,0}", lstt[i].DonGia));
            }
            gcDanhSachDichVu.DataSource = lstt;
        }
        private void ServiceWindow_Load(object sender, EventArgs e)
        {
            srvBUS = new ServiceBUS();
            List <ServiceDTO> listKind = srvBUS.selectKind();

            if (listKind == null)
            {
                MessageBox.Show("Có lỗi khi lấy thông tin từ table Kind");
                return;
            }
            txtKindService.DataSource = listKind;
        }
        //
        //---- LOAD DATA
        //
        #region Load Data

        private void loadData()
        {
            srvBUS = new ServiceBUS();

            List <ServiceDTO> list = srvBUS.select();

            if (list == null)
            {
                MessageBox.Show("Fail");
                return;
            }
            dtgvService.Columns.Clear();
            dtgvService.DataSource = null;

            dtgvService.AutoGenerateColumns = false;
            dtgvService.AllowUserToAddRows  = false;
            dtgvService.DataSource          = list;

            DataGridViewTextBoxColumn NAME = new DataGridViewTextBoxColumn();

            NAME.Name             = "name";
            NAME.HeaderText       = "Name:";
            NAME.DataPropertyName = "name";
            NAME.AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            dtgvService.Columns.Add(NAME);

            DataGridViewTextBoxColumn KIND = new DataGridViewTextBoxColumn();

            KIND.Name             = "kind";
            KIND.HeaderText       = "Kind";
            KIND.DataPropertyName = "kind";
            KIND.AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            dtgvService.Columns.Add(KIND);

            DataGridViewTextBoxColumn COST = new DataGridViewTextBoxColumn();

            COST.Name             = "cost";
            COST.HeaderText       = "Cost";
            COST.DataPropertyName = "cost";
            COST.AutoSizeMode     = DataGridViewAutoSizeColumnMode.Fill;
            dtgvService.Columns.Add(COST);


            CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[dtgvService.DataSource];

            myCurrencyManager.Refresh();
        }
        private void btnXoaDichVu_Click(object sender, EventArgs e)
        {
            DichVuDTO infor = LayThongTinDichVu();

            infor.MaDichVu = int.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["MaDichVu"]).ToString());

            DialogResult result = (MessageBox.Show("Bạn có muốn xóa dịch vụ " + txtTenDichVu.Text + " không?", "Hỏi", MessageBoxButtons.YesNo, MessageBoxIcon.Question));

            if (result == DialogResult.Yes)
            {
                if (ServiceBUS.XoaDichVu(infor))
                {
                    MessageBox.Show("Bạn đã xóa dịch vụ " + txtTenDichVu.Text + " thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frmQuanLiDichVu_Load(sender, e);
                    //KhoiTaoLai();
                }
            }
        }
        private void btAddService_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            errorProvider2.Clear();
            errorProvider3.Clear();


            if (txtNameService.Text == "")
            {
                errorProvider1.SetError(txtNameService, "not null!");
            }
            else if (txtKindService.Text == "")
            {
                errorProvider2.SetError(txtKindService, "not null!");
            }
            else if (txtCostService.Text == "")
            {
                errorProvider3.SetError(txtCostService, "not null!");
            }


            else
            {
                srvBUS = new ServiceBUS();

                ServiceDTO srv = new ServiceDTO();
                srv.IDS  = txtNameService.Text;
                srv.NAME = txtNameService.Text;
                srv.KIND = txtKindService.Text;
                srv.COST = Decimal.Parse(txtCostService.Text);
                bool kq = srvBUS.add(srv);
                if (kq == false)
                {
                    MessageBox.Show("Fail!");
                }
                else
                {
                    MessageBox.Show("Sussces");
                }
                this.loadData();
            }
        }
        private void btnLuuDichVu_Click(object sender, EventArgs e)
        {
            DichVuDTO infor = LayThongTinDichVu();

            if (btnThemDichVu.Text == "Ngừng")
            {
                if (ServiceBUS.ThemDichVu(infor))
                {
                    MessageBox.Show("Bạn đã thêm dịch vụ thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frmQuanLiDichVu_Load(sender, e);
                    btnCapNhatDichVu.Enabled = true;
                    btnXoaDichVu.Enabled     = true;
                    gcDanhSachDichVu.Enabled = true;
                    btnThemDichVu.Text       = "Thêm dịch vụ";
                }
                else
                {
                    MessageBox.Show("Lỗi");
                }
            }
            else if (btnCapNhatDichVu.Text == "Ngừng")
            {
                infor.MaDichVu = int.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["MaDichVu"]).ToString());
                if (ServiceBUS.SuaThongTinDichVu(infor))
                {
                    MessageBox.Show("Bạn đã sửa thông tin dịch vụ " + txtTenDichVu.Text + " thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frmQuanLiDichVu_Load(sender, e);
                    btnThemDichVu.Enabled    = true;
                    btnCapNhatDichVu.Enabled = true;
                    btnXoaDichVu.Enabled     = true;
                    gcDanhSachDichVu.Enabled = true;
                    btnCapNhatDichVu.Text    = "Cập nhật";
                }
                else
                {
                    MessageBox.Show("Lỗi");
                }
            }
        }
        private void btDeleteService_Click(object sender, EventArgs e)
        {
            srvBUS = new ServiceBUS();

            ServiceDTO srv = new ServiceDTO();

            srv.IDS  = txtNameService.Text;
            srv.NAME = txtNameService.Text;
            srv.KIND = txtKindService.Text;
            srv.COST = Decimal.Parse(txtCostService.Text);
            bool kq = srvBUS.delete(srv);

            if (kq == false)
            {
                MessageBox.Show("Fail!");
            }
            else
            {
                MessageBox.Show("Sussces");
            }
            this.loadData();
        }
 public static IEnumerable <CategoryService> GetCateServiceCBB(int id)
 {
     return(ServiceBUS.GetCateServiceCBB(id));
 }
 public static IEnumerable <Service> GetServiceByIDCate(int idCate)
 {
     return(ServiceBUS.GetServiceByIDCate(idCate));
 }
 public static bool UpdateService(Service s)
 {
     return(ServiceBUS.UpdateService(s));
 }
 public static Service GetServiceByID(int id)
 {
     return(ServiceBUS.GetServiceByID(id));
 }
Exemplo n.º 13
0
        private void cmbMaPhong_SelectedIndexChanged(object sender, EventArgs e)
        {
            BillDTO infor = new BillDTO();

            infor.MaPhong = int.Parse(cmbMaPhong.Text);
            List <BillDTO> lst = new List <BillDTO>();

            lst = BillBUS.LayThongTinPhongThue(infor);
            //txtDonGiaPhong.Text = lst[0].DonGia.ToString();
            txtDonGia.Text       = string.Format("{0:0,0}", lst[0].DonGia);
            txtTenKhachHang.Text = lst[0].TenKhachHang.ToString();
            txtDiaChi.Text       = lst[0].DiaChi.ToString();
            int maphieuthue = lst[0].MaPhieuThue.Value;

            infor.NgayBatDauThue = Convert.ToDateTime(lst[0].NgayBatDauThue.ToString());

            BillBUS.TinhSoNgayDaThue(infor);
            lst = BillBUS.LaySoNgayDaThue();
            txtSoNgayThue.Text = lst[0].SoNgayDaThue.ToString();
            if (Convert.ToInt32(txtSoNgayThue.Text) < 0)
            {
                btnThanhToan.Enabled = false;
                MessageBox.Show("Chưa thể thanh toán khách hàng này", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            if (txtSoNgayThue.Text == "0")
            {
                txtSoNgayThue.Text = "1";
            }
            int num = BillBUS.LaySoLuongKhach(maphieuthue);

            lst = BillBUS.LayKhachNuocNgoai();
            int kpt = lst[0].KhachPTThu.Value;
            int kng = lst[0].SLKhachNG.Value;

            if (num >= kpt)
            {
                lst            = BillBUS.TinhPhuThu(num);
                txtPhuThu.Text = lst[0].PhuThu.ToString();
            }
            else
            {
                txtPhuThu.Text = "0";
            }
            int nc = BillBUS.DemSoLuongKhachNuocNgoai(infor);

            if (nc >= kng)
            {
                lst          = BillBUS.TinhHeSo();
                txtHeSo.Text = lst[0].HeSo.ToString();
            }
            else
            {
                txtHeSo.Text = "0";
            }
            decimal phidichvu = 0;
            int     numdv     = OderDichVuBUS.LaySoLuongDichVuDK(infor.MaPhong);

            if (numdv == 0)
            {
                txtPhiDichVu.Text = "0";
            }
            else
            {
                for (int i = 0; i < numdv; i++)
                {
                    List <OderServiceDTO> lst2   = new List <OderServiceDTO>();
                    OderServiceDTO        infor2 = new OderServiceDTO();
                    lst2            = OderDichVuBUS.DanhSachDichVuDK(infor.MaPhong);
                    infor2.MaDichVu = lst2[i].MaDichVu;
                    infor2.SoLuong  = lst2[i].SoLuong;
                    List <ServiceDTO> lst3 = new List <ServiceDTO>();
                    lst3 = ServiceBUS.LayDonGia(infor2.MaDichVu);
                    ServiceDTO dongiadv = new ServiceDTO();
                    dongiadv.DonGia = lst3[0].DonGia;
                    decimal tiendv = dongiadv.DonGia;
                    phidichvu += infor2.SoLuong * tiendv;
                }
                txtPhiDichVu.Text = string.Format("{0:0,0  }", phidichvu);
            }


            bool flag = true;

            for (int i = 0; i < dgvHoaDon.RowCount; i++)
            {
                if (dgvHoaDon.Rows[i].Cells["colMaPhong"].Value.ToString() != null)
                {
                    if (dgvHoaDon.Rows[i].Cells["colMaPhong"].Value.ToString() == cmbMaPhong.Text)
                    {
                        btnThemHoaDon.Enabled = false;
                        flag = false;
                        break;
                    }
                }
            }

            if (flag == true)
            {
                btnThemHoaDon.Enabled = true;
            }
        }
 public static bool DelService(int id)
 {
     return(ServiceBUS.DelService(id));
 }
 public static IEnumerable <Service> GetAllService()
 {
     return(ServiceBUS.GetAllService());
 }
 public static bool CreateCateService(CategoryService cs)
 {
     return(ServiceBUS.CreateCateService(cs));
 }
 public static IEnumerable <CategoryService> GetAllCateService()
 {
     return(ServiceBUS.GetAllCateService());
 }
 public static CategoryService GetCateSeerviceByID(int id)
 {
     return(ServiceBUS.GetCateServiceByID(id));
 }
 public static bool CreateService(Service s)
 {
     return(ServiceBUS.CreateService(s));
 }