private void btnCapNhat_Click(object sender, EventArgs e)
        {
            if (!IsValidInputData())
            {
                return;
            }
            var dr = MMessageBox.Show(this, "Lưu thực đơn?", "Thông báo"
                                      , MMessageBoxButtons.YesNo, MMessageBoxIcon.Warning);

            if (DialogResult.No == dr)
            {
                Dispose();
                return;
            }
            var menuCode    = txtMenuCode.Text.Trim();
            var menuName    = txtMenuName.Text.Trim();
            var unitId      = MControlUtil.GetValueFromCombobox(cboUnit);
            var price       = txtPrice.Text.Trim();
            var description = txtDescription.Text.Trim();
            var dto         = new MenuDto()
            {
                Id          = _menuId,
                Code        = menuCode,
                Name        = menuName,
                CategoryId  = _categoryId,
                UnitId      = long.Parse(unitId),
                Price       = float.Parse(price),
                Description = description
            };

            _billingDao.SaveMenu(dto);
            _isChange = true;
            Dispose();
        }
示例#2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (!IsValidInputData())
            {
                return;
            }
            var dr = MMessageBox.Show(this, "Lưu hóa đơn?", "Thông báo"
                                      , MMessageBoxButtons.YesNo, MMessageBoxIcon.Warning);

            if (DialogResult.No == dr)
            {
                Dispose();
                return;
            }
            string tableNumber   = cboBanSo.Text;
            string billingNumber = txtHoaDonSo.Text;

            _billNumber = tableNumber + "_" + billingNumber;
            var billDto = new BillDto();

            billDto.Id = _billId;
            var tableId = MControlUtil.GetValueFromCombobox(cboBanSo);

            billDto.TableId       = long.Parse(tableId);
            billDto.BillingNumber = int.Parse(billingNumber);
            billDto.EmployeeId    = MControlUtil.GetValueFromCombobox(cboEmployee);
            billDto.EmployeeName  = cboEmployee.Text.Trim();
            string currentUserName = _danhSachUser.GetCurrentUserName();

            billDto.CreatedBy = currentUserName;
            billDto.UpdatedBy = currentUserName;
            _billingDao.SaveBill(billDto);
            _isChange = true;
            Dispose();
        }
        private void btnThucHien_Click(object sender, EventArgs e)
        {
            if (!IsValidInputData())
            {
                return;
            }
            var searchDto      = CreateSearchDto();
            var allResOrderDto = _billingDao.GetAllResOrderDto(searchDto);

            var selectedIndex = GetSelectedSellIndex();

            if (selectedIndex > allResOrderDto.Count - 1)
            {
                selectedIndex = allResOrderDto.Count - 1;
            }
            sellDataGridView.Rows.Clear();
            float tongSo = 0;

            foreach (var dto in allResOrderDto)
            {
                AddOneSellRow(dto);
                tongSo += dto.Total;
            }
            txtTongSo.Text = tongSo.ToString("#,###,###") + " VNĐ";
            MControlUtil.SetSelectedIndex(sellDataGridView, selectedIndex, "menu");
        }
        private void btnThucHien_Click(object sender, EventArgs e)
        {
            if (!IsValidInputData())
            {
                return;
            }
            var fromDate = txtFromDate.Text.Trim();
            var toDate   = txtToDate.Text.Trim();

            List <StatisticStoreDto> listDto = _storeDao.GetStatisticStores(fromDate, toDate);
            var selectedIndex = GetSelectedStoreIndex();

            if (selectedIndex > listDto.Count - 1)
            {
                selectedIndex = listDto.Count - 1;
            }

            inventoryDataGridView.Rows.Clear();

            foreach (StatisticStoreDto dto in listDto)
            {
                AddOneRow(dto);
            }
            MControlUtil.SetSelectedIndex(inventoryDataGridView, selectedIndex, "material");
        }
示例#5
0
        private void dgvHoaDon_SelectionChanged(object sender, EventArgs e)
        {
            var billId  = GetSelectedBillId();
            var billDto = _billingDao.getBillDto(billId);

            txtInHoaDon.Text = ConstUtil.YES.Equals(billDto.IsPrinted) ? "Đã in" : "Chưa in";
            string thanhToan = GetThanhToan(billDto.Payment);

            txtThanhToan.Text = thanhToan;
            var allResOrderDtos = _billingDao.GetAllResOrderBy(billId);
            var selectedIndex   = GetSelectedResOrderIndex();

            if (selectedIndex > allResOrderDtos.Count - 1)
            {
                selectedIndex = allResOrderDtos.Count - 1;
            }
            dgvThucDon.Rows.Clear();
            float tongTien = 0;
            float oneTotal;

            foreach (var dto in allResOrderDtos)
            {
                AddOneResOrderRow(dto, out oneTotal);
                tongTien += oneTotal;
            }
            MControlUtil.SetSelectedIndex(dgvThucDon, selectedIndex, "MON_AN");
            string tongVal = tongTien.ToString("#,###,###");

            txtTongTien.Text = string.IsNullOrEmpty(tongVal) ? string.Empty : tongVal + " VNĐ";
        }
示例#6
0
        private void btnThemMonAn_Click(object sender, EventArgs e)
        {
            if (!IsValidInputData())
            {
                return;
            }
            var resOrderDto = new ResOrderDto();

            resOrderDto.MenuId = long.Parse(MControlUtil.GetValueFromCombobox(cboMonAn));
            resOrderDto.BillId = GetSelectedBillId();
            resOrderDto.Amount = long.Parse(txtSoLuong.Text);
            var disCount = 0.0f;

            if (!"".Equals(txtChietKhau.Text))
            {
                disCount = long.Parse(txtChietKhau.Text) / 100.0f;
            }
            resOrderDto.Discount = disCount;
            string currentUserName = _danhSachUser.GetCurrentUserName();

            resOrderDto.CreatedBy = currentUserName;
            resOrderDto.UpdatedBy = currentUserName;
            _billingDao.AddNewResOrder(resOrderDto);
            dgvHoaDon_SelectionChanged(null, null);
        }
        private void InitQuyComboBox()
        {
            var currentYear   = DateUtil.GetNamHienTai();
            var currentQuater = DateUtil.GetQuyHienTai();
            var allDto        = new List <DanhMucDto>();

            for (int i = currentQuater; i > 0; i--)
            {
                var value = i + "/" + currentYear;
                allDto.Add(new DanhMucDto()
                {
                    Id  = Convert.ToString(value),
                    Ten = Convert.ToString(value)
                });
            }
            var previousYear = int.Parse(currentYear) - 1;

            for (int i = 4; i > 0; i--)
            {
                var value = i + "/" + previousYear;
                allDto.Add(new DanhMucDto()
                {
                    Id  = Convert.ToString(value),
                    Ten = Convert.ToString(value)
                });
            }
            MControlUtil.FillToComboBox(quyComboBox, allDto);
            quyComboBox.Text = currentQuater + "/" + currentYear;
        }
        public MenuProcessing(long categoryId, long menuId)
        {
            InitializeComponent();
            var allUnitDto = _billingDao.GetAllUnit();

            MControlUtil.FillToComboBox(cboUnit, allUnitDto);

            _categoryId = categoryId;
            _menuId     = menuId;
            if (categoryId != -1)
            {
                var categoryDto = _billingDao.getCategoryDto(categoryId);
                txtCategory.Text = categoryDto.Ten;
                txtMenuCode.Text = categoryDto.Id;
            }
            if (menuId != -1)
            {
                var menuDto = _billingDao.getMenuDto(menuId);
                txtMenuCode.Text    = menuDto.Code;
                txtMenuName.Text    = menuDto.Name;
                cboUnit.Text        = menuDto.UnitName;
                txtPrice.Text       = Convert.ToString(menuDto.Price);
                txtDescription.Text = menuDto.Description;
            }
        }
        private void FillBill2Grid(List <BillDto> allBillDto)
        {
            var selectedIndex = GetSelectedBillIndex();

            if (selectedIndex > allBillDto.Count - 1)
            {
                selectedIndex = allBillDto.Count - 1;
            }
            dgvBilling.Rows.Clear();
            foreach (var billDto in allBillDto)
            {
                AddOneBillRow(billDto);
            }
            MControlUtil.SetSelectedIndex(dgvBilling, selectedIndex, "billNumber");
        }
        private void FillData2Grid(List <UserDto> allUserDto)
        {
            var selectedIndex = GetSelectedUserIndex();

            if (selectedIndex > allUserDto.Count - 1)
            {
                selectedIndex = allUserDto.Count - 1;
            }
            dgvUser.Rows.Clear();
            foreach (var dto in allUserDto)
            {
                AddOneUserRow(dto);
            }
            MControlUtil.SetSelectedIndex(dgvUser, selectedIndex, "UserName");
        }
        private void btnThucHien_Click(object sender, EventArgs e)
        {
            if (!IsValidInputData())
            {
                return;
            }
            var tuNgay        = txtFromDate.Text.Trim();
            var denNgay       = txtToDate.Text.Trim();
            var billingNumber = txtBillingNumber.Text.Trim();
            var tableId       = MControlUtil.GetValueFromCombobox(tableComboBox);
            var billStatus    = MControlUtil.GetValueFromCombobox(billStatusComboBox);
            var allBillDto    = _billingDao.GetAllBillBy(tuNgay, denNgay, billingNumber, tableId, billStatus);

            FillBill2Grid(allBillDto);
        }
        private void InitComboTable()
        {
            var allResTableDtos = _billingDao.GetAllResTableDto();
            var allDanhMucDto   = new List <DanhMucDto>();

            foreach (ResTableDto dto in allResTableDtos)
            {
                allDanhMucDto.Add(new DanhMucDto()
                {
                    Id  = Convert.ToString(dto.Id),
                    Ma  = dto.Code,
                    Ten = dto.Position
                });
            }
            MControlUtil.FillToComboBox(tableComboBox, allDanhMucDto);
        }
示例#13
0
        private void FillBill2Grid()
        {
            var allBillDto    = _billingDao.GetAllNotCompletedBill();
            var selectedIndex = GetSelectedBillIndex();

            if (selectedIndex > allBillDto.Count - 1)
            {
                selectedIndex = allBillDto.Count - 1;
            }
            dgvHoaDon.Rows.Clear();
            foreach (var billDto in allBillDto)
            {
                AddOneBillRow(billDto);
            }
            MControlUtil.SetSelectedIndex(dgvHoaDon, selectedIndex, "billNumber");
            dgvHoaDon_SelectionChanged(null, null);
        }
示例#14
0
        public BillingAdd(long billId)
        {
            InitializeComponent();
            _billId = billId;

            var allResTableDtos = _billingDao.GetAllResTableDto();
            var allDanhMucDto   = new List <DanhMucDto>();

            foreach (ResTableDto dto in allResTableDtos)
            {
                allDanhMucDto.Add(new DanhMucDto()
                {
                    Id  = Convert.ToString(dto.Id),
                    Ma  = dto.Code,
                    Ten = dto.Position
                });
            }
            MControlUtil.FillToComboBox(cboBanSo, allDanhMucDto);

            var allEmployeeDto = _billingDao.GetAllEmployee();

            allDanhMucDto = new List <DanhMucDto>();
            foreach (EmployeeDto dto in allEmployeeDto)
            {
                allDanhMucDto.Add(new DanhMucDto()
                {
                    Id  = Convert.ToString(dto.Id),
                    Ma  = dto.EmployeeId,
                    Ten = dto.FullName
                });
            }
            MControlUtil.FillToComboBox(cboEmployee, allDanhMucDto);

            if (billId != -1)
            {
                var billDto = _billingDao.getBillDto(billId);
                cboBanSo.SelectedValue = Convert.ToString(billDto.TableId);
                cboEmployee.Text       = billDto.EmployeeName;
                txtHoaDonSo.Text       = Convert.ToString(billDto.BillingNumber);
                string tableNumber   = cboBanSo.Text;
                string billingNumber = txtHoaDonSo.Text;
                _billNumber  = tableNumber + "_" + billingNumber;
                this.Text    = "Cập nhật";
                btnThem.Text = "Cập nhật";
            }
        }
示例#15
0
        private void FillData2CategoryGrid()
        {
            var allCategoryDto = _billingDao.GetAllCategory();
            var selectedIndex  = GetSelectedCategoryIndex();

            if (selectedIndex > allCategoryDto.Count - 1)
            {
                selectedIndex = allCategoryDto.Count - 1;
            }
            dgvCategory.Rows.Clear();
            foreach (var dto in allCategoryDto)
            {
                AddOneCategoryRow(dto);
            }
            MControlUtil.SetSelectedIndex(dgvCategory, selectedIndex, "code");
            dgvCategory_SelectionChanged(null, null);
        }
        private void InitNamComboBox()
        {
            var currentYear = DateUtil.GetNamHienTai();
            var allDto      = new List <DanhMucDto>();

            for (int i = 0; i <= 10; i++)
            {
                var value = int.Parse(currentYear) - i;
                allDto.Add(new DanhMucDto()
                {
                    Id  = Convert.ToString(value),
                    Ten = Convert.ToString(value)
                });
            }
            MControlUtil.FillToComboBox(namComboBox, allDto);
            namComboBox.Text = currentYear;
        }
示例#17
0
        private void InitDataGridView(List <DanhMucDto> allDto)
        {
            int selectedIndex = dgvLov.CurrentRow == null ? 0 : dgvLov.CurrentRow.Index;

            dgvLov.Rows.Clear();
            foreach (var dto in allDto)
            {
                OnAddOneRow(dgvLov.Rows, dto);
            }
            if (selectedIndex >= allDto.Count)
            {
                selectedIndex = allDto.Count - 1;
            }
            if (selectedIndex >= 0)
            {
                MControlUtil.SetSelectedIndex(dgvLov, selectedIndex, "MA");
            }
        }
        private void InitThangComboBox()
        {
            var currentDate = DateUtil.GetCurrentDateTime();
            var allDto      = new List <DanhMucDto>();

            for (int i = 0; i <= 12; i++)
            {
                var value = DateUtil.GetDateTimeAsDdmmyyyy(currentDate.AddMonths(-i)).Substring(3);
                allDto.Add(new DanhMucDto()
                {
                    Id  = value,
                    Ten = value
                });
            }
            MControlUtil.FillToComboBox(thangComboBox, allDto);
            var currentMonth = DateUtil.GetDateTimeAsDdmmyyyy(currentDate).Substring(3);

            thangComboBox.Text = currentMonth;
        }
示例#19
0
        private bool IsValidInputData()
        {
            if ("".Equals(txtCategory.Text.Trim()))
            {
                MMessageBox.Show(this, "Nhóm thực đơn không tồn tại", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtCategory.Focus();
                return(false);
            }
            string menuCode = txtMenuCode.Text.Trim();

            if ("".Equals(menuCode))
            {
                MMessageBox.Show(this, "Bạn chưa nhập mã thực đơn", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMenuCode.Focus();
                return(false);
            }
            if ("".Equals(txtMenuName.Text.Trim()))
            {
                MMessageBox.Show(this, "Bạn chưa nhập tên thực đơn", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMenuName.Focus();
                return(false);
            }
            var unitId = MControlUtil.GetValueFromCombobox(cboUnit);

            if ("".Equals(unitId))
            {
                MMessageBox.Show(this, "Bạn chưa chọn đơn vị", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                cboUnit.Focus();
                return(false);
            }
            if ("".Equals(txtPrice.Text.Trim()))
            {
                MMessageBox.Show(this, "Bạn chưa nhập giá", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtPrice.Focus();
                return(false);
            }
            return(true);
        }
示例#20
0
        public ThongTinKhachTT(float tongTien, string tenNhanVien)
        {
            InitializeComponent();
            _tongTien    = tongTien;
            _tenNhanVien = tenNhanVien;
            var allEmployeeDto = _billingDao.GetAllEmployee();
            var allDanhMucDto  = new List <DanhMucDto>();

            foreach (EmployeeDto dto in allEmployeeDto)
            {
                allDanhMucDto.Add(new DanhMucDto()
                {
                    Id  = Convert.ToString(dto.Id),
                    Ma  = dto.EmployeeId,
                    Ten = dto.FullName
                });
            }
            MControlUtil.FillToComboBox(cboEmployee, allDanhMucDto, tenNhanVien);
        }
示例#21
0
        public BillingProcessing()
        {
            InitializeComponent();

            var allMenuDtos   = _billingDao.GetAllMenuDto();
            var allDanhMucDto = new List <DanhMucDto>();

            foreach (MenuDto dto in allMenuDtos)
            {
                allDanhMucDto.Add(new DanhMucDto()
                {
                    Id  = Convert.ToString(dto.Id),
                    Ma  = dto.Code,
                    Ten = dto.Name
                });
            }
            MControlUtil.FillToComboBox(cboMonAn, allDanhMucDto);
            txtChietKhau.Text = "0";

            FillBill2Grid();
        }
示例#22
0
        private void dgvCategory_SelectionChanged(object sender, EventArgs e)
        {
            var categoryId = GetSelectedCategoryId();

            if (categoryId == -1)
            {
                return;
            }
            var allMenuDto    = _billingDao.GetAllMenuBy(categoryId);
            var selectedIndex = GetSelectedMenuIndex();

            if (selectedIndex > allMenuDto.Count - 1)
            {
                selectedIndex = allMenuDto.Count - 1;
            }
            dgvMenu.Rows.Clear();
            foreach (var dto in allMenuDto)
            {
                AddOneMenuRow(dto);
            }
            MControlUtil.SetSelectedIndex(dgvMenu, selectedIndex, "menuCode");
        }
        private void InitComboStatus()
        {
            var allDanhMucDto = new List <DanhMucDto>();

            allDanhMucDto.Add(new DanhMucDto()
            {
                Id  = ConstUtil.CANCEL,
                Ma  = ConstUtil.CANCEL,
                Ten = "Hủy"
            });
            allDanhMucDto.Add(new DanhMucDto()
            {
                Id  = ConstUtil.NO,
                Ma  = ConstUtil.NO,
                Ten = "Chưa thanh toán"
            });
            allDanhMucDto.Add(new DanhMucDto()
            {
                Id  = ConstUtil.YES,
                Ma  = ConstUtil.YES,
                Ten = "Đã thanh toán"
            });
            MControlUtil.FillToComboBox(billStatusComboBox, allDanhMucDto);
        }