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

            if (DialogResult.No == dr)
            {
                Dispose();
                return;
            }
            var maNhom  = txtMaNhom.Text.Trim();
            var tenNhom = txtTenNhom.Text.Trim();
            var dto     = new DanhMucDto()
            {
                Id  = Convert.ToString(_categoryId),
                Ma  = maNhom,
                Ten = tenNhom
            };

            _billingDao.SaveCategory(dto);
            _isChange = true;
            Dispose();
        }
        private bool IsValidInputData()
        {
            string maNhom = txtMaNhom.Text.Trim();

            if ("".Equals(maNhom))
            {
                MMessageBox.Show(this, "Bạn chưa nhập mã nhóm", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMaNhom.Focus();
                return(false);
            }
            if (_billingDao.IsExistCategoryCode(maNhom, _categoryId))
            {
                MMessageBox.Show(this, "Mã nhóm đã tồn tại, vui lòng nhập lại", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMaNhom.Focus();
                return(false);
            }
            if ("".Equals(txtTenNhom.Text.Trim()))
            {
                MMessageBox.Show(this, "Bạn chưa nhập tên nhóm", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtTenNhom.Focus();
                return(false);
            }
            return(true);
        }
예제 #3
0
 private bool IsValidInputData()
 {
     if ("".Equals(cboEmployee.Text.Trim()))
     {
         MMessageBox.Show(this, "Bạn chưa chọn nhân viên", "Thông báo"
                          , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
         cboEmployee.Focus();
         return(false);
     }
     if ("".Equals(txtHoaDonSo.Text.Trim()))
     {
         MMessageBox.Show(this, "Bạn chưa nhập số hóa đơn", "Thông báo"
                          , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
         txtHoaDonSo.Focus();
         return(false);
     }
     if ("".Equals(cboBanSo.Text.Trim()))
     {
         MMessageBox.Show(this, "Bạn chưa chọn số bàn", "Thông báo"
                          , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
         cboBanSo.Focus();
         return(false);
     }
     return(true);
 }
예제 #4
0
        private void btnHuy_Click(object sender, EventArgs e)
        {
            var billId = GetSelectedBillId();

            if (billId == -1)
            {
                MMessageBox.Show(this, "Bạn chưa chọn hóa đơn", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                btnThemHoaDon.Focus();
                return;
            }
            var dr = MMessageBox.Show(this, "Bạn có muốn hủy hóa đơn?", "Thông báo"
                                      , MMessageBoxButtons.YesNo, MMessageBoxIcon.Warning);

            if (DialogResult.No == dr)
            {
                return;
            }
            var billingCancel = new BillingCancel();

            billingCancel.ShowDialog(this);
            var reason = billingCancel.Reason;

            if (String.IsNullOrEmpty(reason))
            {
                return;
            }
            var billDto = _billingDao.getBillDto(billId);

            billDto.Payment      = ConstUtil.CANCEL;
            billDto.CancelReason = reason;
            _billingDao.ThanhToan(billDto);
            dgvHoaDon_SelectionChanged(null, null);
        }
예제 #5
0
        private bool IsValidInputData()
        {
            var billId = GetSelectedBillId();

            if (billId == -1)
            {
                MMessageBox.Show(this, "Bạn chưa chọn hóa đơn", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                btnThemHoaDon.Focus();
                return(false);
            }

            if ("".Equals(cboMonAn.Text.Trim()))
            {
                MMessageBox.Show(this, "Bạn chưa chọn món ăn", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                cboMonAn.Focus();
                return(false);
            }
            if ("".Equals(txtSoLuong.Text.Trim()) || long.Parse(txtSoLuong.Text.Trim()) == 0)
            {
                MMessageBox.Show(this, "Bạn chưa nhập số lượng", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtSoLuong.Focus();
                return(false);
            }
            return(true);
        }
예제 #6
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();
        }
예제 #7
0
        private void btnDongY_Click(object sender, EventArgs e)
        {
            var userDto     = _danhSachUser.CheckUser(txtUserName.Text.Trim(), txtPassword.Text.Trim());
            var messageText = userDto.Message;

            if (String.IsNullOrEmpty(messageText))
            {
                ThamSo.Username     = txtUserName.Text.Trim();
                ThamSo.UserId       = userDto.UserID.ToString();
                ThamSo.UserRoleList = UserUtil.getAllRoleCode(userDto);
                Close();
                if (_successHandler != null)
                {
                    _successHandler(this, e);
                }
            }
            else
            {
                MMessageBox.Show(this, messageText, "Lỗi"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Error);
                failLoginTime++;
                if (failLoginTime >= 3)
                {
                    Application.Exit();
                }
            }
        }
예제 #8
0
        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();
        }
예제 #9
0
        private void mnuThoat_Click(object sender, System.EventArgs e)
        {
            var dr = MMessageBox.Show(this, "Bạn có muốn thoát khỏi chương trình?", "Cảnh báo"
                                      , MMessageBoxButtons.YesNo, MMessageBoxIcon.Question);

            if (DialogResult.Yes == dr)
            {
                OnCancelLogin(null, null);
            }
        }
예제 #10
0
 private void mButton1_Click(object sender, EventArgs e)
 {
     if (!IsValidInputData())
     {
         return;
     }
     MMessageBox.Show(this, "Đổi mật khẩu thành công", "Thông báo"
                      , MMessageBoxButtons.OK, MMessageBoxIcon.Information);
     DialogResult = DialogResult.OK;
 }
 private bool IsValidInputData()
 {
     if (String.IsNullOrEmpty(txtFromDate.Text))
     {
         MMessageBox.Show(this, "Bạn chưa nhập Từ ngày", "Thông báo"
                          , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
         txtFromDate.Focus();
         return(false);
     }
     return(true);
 }
예제 #12
0
        /// <summary>
        /// Ham nay thiet lap gia tri cho Cell trong Table
        ///
        /// </summary>
        /// <param name="colIndex">Chi so cua column chua Cell, bat dau tu 1</param>
        /// <param name="row">row trong Table</param>
        /// <param name="value">Gia tri cho Cell</param>

        public static void SetValueForTableCell(Row row, int colIndex, string value)
        {
            try
            {
                row.Cells.Item(colIndex).Range.Text = value;
            }
            catch (Exception exception)
            {
                MMessageBox.Show(null, exception.Message);
            }
        }
예제 #13
0
        private void btnImpexpProcess_Click(object sender, EventArgs e)
        {
            _storeDao.AddList(listStoreDto);

            MMessageBox.Show(this, "Bạn đã " + importExportType.name.ToLower() + " thành công", "Thông báo"
                             , MMessageBoxButtons.OK, MMessageBoxIcon.Information);

            ResetForm();

            return;
        }
예제 #14
0
 public static void Merge2Cell(Cell MergeFrom, Cell MergeTo)
 {
     try
     {
         MergeFrom.Merge(MergeTo);
     }
     catch (Exception exception)
     {
         MMessageBox.Show(null, exception.Message);
     }
 }
예제 #15
0
 private bool IsValidInputData()
 {
     if ("".Equals(txtReason.Text.Trim()))
     {
         MMessageBox.Show(this, "Bạn chưa nhập lý do", "Thông báo"
                          , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
         txtReason.Focus();
         return(false);
     }
     return(true);
 }
예제 #16
0
 public static void SetStyleForCell(Cell cell, object style)
 {
     try
     {
         cell.Range.set_Style(style);
     }
     catch (Exception exception)
     {
         MMessageBox.Show(null, exception.Message);
     }
 }
예제 #17
0
        public static void SetStyleForCell(Cell cell)
        {
            try
            {
//                cell.Range.Font.Bold = 0;
                cell.WordWrap = false;
            }
            catch (Exception exception)
            {
                MMessageBox.Show(null, exception.Message);
            }
        }
예제 #18
0
 /// <summary>
 /// Hàm này dùng để thêm một(hoặc nhiều) row mới vào trước một row cho trước trong table
 /// </summary>
 /// <param name="rowIndex">index của row cho trước</param>
 /// <param name="numRow">số row cần bổ sung</param>
 public static void AddRowsAbove(int index, int rowIndex, int numRow)
 {
     try
     {
         Table tbl = _doc.Content.Tables.Item(index);
         tbl.Rows.Item(rowIndex).Select();
         _msWord.Selection.InsertRowsAbove(numRow);
     }
     catch (Exception exception)
     {
         MMessageBox.Show(null, exception.Message);
     }
 }
예제 #19
0
 public static void SetStyleForCell(Cell cell, bool isBold, bool isItalic, bool isUnderline)
 {
     try
     {
         //row.Range.set_Style(ref style);
         cell.Range.Font.Bold      = isBold ? 1 : 0;
         cell.Range.Font.Underline = isUnderline ? WdUnderline.wdUnderlineSingle : WdUnderline.wdUnderlineNone;
         cell.WordWrap             = false;
     }
     catch (Exception exception)
     {
         MMessageBox.Show(null, exception.Message);
     }
 }
예제 #20
0
        public bool IsValidInputData()
        {
            if (String.IsNullOrEmpty(txtFullName.Text.Trim()))
            {
                MMessageBox.Show(this, "Bạn phải nhập tên người dùng", "Thông báo", MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtFullName.Focus();
                return(false);
            }

            var username = txtUsername.Text.Trim();

            if (String.IsNullOrEmpty(username))
            {
                MMessageBox.Show(this, "Bạn phải nhập thông tin Mã đăng nhập", "Thông báo", MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtUsername.Focus();
                return(false);
            }

            if (_danhSachUser.ExistsUser(_userID, username))
            {
                MMessageBox.Show(this, "Đã tồn tại người dùng trong hệ thống", "Thông báo", MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtUsername.Focus();
                return(false);
            }

            if (IsNewUser() && String.IsNullOrEmpty(txtMkMoi.Text.Trim()))
            {
                MMessageBox.Show(this, "Bạn phải nhập thông tin Mật khẩu", "Thông báo", MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMkMoi.Focus();
                return(false);
            }

            if (IsNewUser() && String.IsNullOrEmpty(txtMkMoi2.Text.Trim()))
            {
                MMessageBox.Show(this, "Bạn phải nhập thông tin Mật khẩu xác nhận", "Thông báo", MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMkMoi2.Focus();
                return(false);
            }

            if (IsNewUser() && !txtMkMoi.Text.Equals(txtMkMoi2.Text.Trim()))
            {
                MMessageBox.Show(this, "Mật khẩu xác nhận không khớp", "Thông báo", MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMkMoi.Text  = "";
                txtMkMoi2.Text = "";
                txtMkMoi.Focus();
                return(false);
            }

            return(true);
        }
예제 #21
0
        public static void FillDataToWordDocTableWithoutStt2(int index, bool isBold, bool isItalic, bool isUnderline, bool includeHeader, bool includeSumRow, bool isFirstTime)
        {
            if (_doc == null)
            {
                return;
            }
            if (_doc.Tables.Count == 0)
            {
                return;
            }

            if (index < 1)
            {
                throw new ArgumentException("Index phai >=1");
            }

            try
            {
                Table tbl1         = _doc.Content.Tables.Item(index);
                var   lastRowIndex = includeSumRow ? tbl1.Rows.Count - 1 : tbl1.Rows.Count;
                if (lastRowIndex == 0)
                {
                    lastRowIndex = 1;
                }
                int prev = lastRowIndex;
                if (isFirstTime)
                {
                    if (SourceTable.Rows.Count > 1)
                    {
                        AddRowsBelow(index, prev, SourceTable.Rows.Count - 1);
                    }
                }
                else
                {
                    AddRowsBelow(index, prev, SourceTable.Rows.Count);
                    prev++;
                }
                foreach (DataRow sRow in SourceTable.Rows)
                {
                    Row row = tbl1.Rows.Item(prev);
                    SetAllValueForTableRowWithStyle(row, AllValues2(sRow, ColumnNames), isBold, isItalic, isUnderline);
                    prev++;
                }
            }
            catch (Exception exception)
            {
                MMessageBox.Show(null, exception.Message);
            }
        }
예제 #22
0
 private void dgvThucDon_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvThucDon.Columns[e.ColumnIndex].Name == "Delete")
     {
         var resOrderId = GetSelectedResOrderId();
         var dr         = MMessageBox.Show(this, "Bạn có muốn loại bỏ thực đơn?", "Thông báo"
                                           , MMessageBoxButtons.YesNo, MMessageBoxIcon.Warning);
         if (DialogResult.No == dr)
         {
             return;
         }
         _billingDao.DeleteResOrder(resOrderId);
         dgvHoaDon_SelectionChanged(null, null);
     }
 }
예제 #23
0
        public static void DoMergeCell(int index, Hashtable mapMergeCell)
        {
            if (_doc == null)
            {
                return;
            }
            if (_doc.Tables.Count == 0)
            {
                return;
            }

            if (index < 1)
            {
                throw new ArgumentException("Index phai >=1");
            }

            try
            {
                Table        tbl1 = _doc.Content.Tables.Item(index);
                List <Point> keys = new List <Point>();
                foreach (Point key in mapMergeCell.Keys)
                {
                    keys.Add(key);
                }
                keys.Sort(Compare2Cell);
                foreach (Point one in keys)
                {
                    List <Point> listPoint = new List <Point>((List <Point>)mapMergeCell[one]);
                    listPoint.Add(one);
                    listPoint.Sort(Compare2Cell);
                    for (int i = 0; i < listPoint.Count; i++)
                    {
                        if (i < listPoint.Count - 1)
                        {
                            var  startPoint = listPoint[i];
                            var  nextPoint  = listPoint[i + 1];
                            Cell startCell  = tbl1.Cell(startPoint.X, startPoint.Y);
                            Cell nextCell   = tbl1.Cell(nextPoint.X, nextPoint.Y);
                            Merge2Cell(startCell, nextCell);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                MMessageBox.Show(null, exception.Message);
            }
        }
예제 #24
0
 public static void OpenWordDocument(string fileName)
 {
     try
     {
         if (!Path.GetExtension(fileName).ToLower().Equals(".doc") &&
             !Path.GetExtension(fileName).ToLower().Equals(".docx"))
         {
             return;
         }
         Process.Start(fileName);
     }
     catch (Exception ex)
     {
         MMessageBox.Show(null, "Khong mo dc File");
     }
 }
예제 #25
0
 public static void SetAllValueForTableRowWithStyle(Row row, Hashtable rowHashTable, bool isBold, bool isItalic, bool isUnderline)
 {
     try
     {
         foreach (var key in rowHashTable.Keys)
         {
             int colIndex = (int)key;
             row.Cells.Item(colIndex).Range.Text = Convert.ToString(rowHashTable[key]);
             SetStyleForCell(row.Cells.Item(colIndex), isBold, isItalic, isUnderline);
         }
     }
     catch (Exception exception)
     {
         MMessageBox.Show(null, exception.Message);
     }
 }
예제 #26
0
        private Boolean IsValidInputData()
        {
            if ("".Equals(txtMkCu.Text.Trim()))
            {
                MMessageBox.Show(this, "Bạn chưa nhập mật khẩu cũ", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMkCu.Focus();
                return(false);
            }

            if (!_danhSachUser.changePassword(_userId, txtMkMoi.Text.Trim(), txtMkCu.Text.Trim()))
            {
                MMessageBox.Show(this, "Mật khẩu cũ không đúng", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMkCu.Text = "";
                txtMkCu.Focus();
                return(false);
            }

            if ("".Equals(txtMkMoi.Text.Trim()))
            {
                MMessageBox.Show(this, "Bạn chưa nhập mật khẩu mới", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMkMoi.Focus();
                return(false);
            }

            if ("".Equals(txtMkMoi2.Text.Trim()))
            {
                MMessageBox.Show(this, "Bạn chưa nhập mật khẩu xác nhận", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMkMoi2.Focus();
                return(false);
            }

            if (!txtMkMoi.Text.Equals(txtMkMoi2.Text.Trim()))
            {
                MMessageBox.Show(this, "Mật khẩu xác nhận không khớp", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtMkMoi.Text  = "";
                txtMkMoi2.Text = "";
                txtMkMoi.Focus();
                return(false);
            }

            return(true);
        }
예제 #27
0
 public static void SetAllValueForTableRow(Table tbl1, int rowIndex, Hashtable rowHashTable)
 {
     try
     {
         foreach (var key in rowHashTable.Keys)
         {
             int colIndex = (int)key;
             var cell     = tbl1.Cell(rowIndex, colIndex);
             cell.Range.Text = Convert.ToString(rowHashTable[key]);
             SetStyleForCell(cell);
         }
     }
     catch (Exception exception)
     {
         MMessageBox.Show(null, exception.Message);
     }
 }
예제 #28
0
        private void btnDongY_Click(object sender, EventArgs e)
        {
            if (!IsValidInputData())
            {
                return;
            }
            var dr = MMessageBox.Show(this, "Lưu người dùng?", "Thông báo"
                                      , MMessageBoxButtons.YesNo, MMessageBoxIcon.Warning);

            if (DialogResult.No == dr)
            {
                Dispose();
                return;
            }
            _danhSachUser.SaveUser(CreateUserDto());
            _isChange    = true;
            DialogResult = DialogResult.OK;
        }
예제 #29
0
        private void btnAddStore_Click(object sender, EventArgs e)
        {
            var materialDto = (MaterialDto)materialComboBox.SelectedItem;

            if (materialComboBox == null)
            {
                MMessageBox.Show(this, "Bạn chưa chọn loại nguyên liệu", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                materialComboBox.Focus();
                return;
            }

            if (String.IsNullOrEmpty(txtAmount.Text))
            {
                MMessageBox.Show(this, "Bạn chưa nhập số lượng", "Thông báo"
                                 , MMessageBoxButtons.OK, MMessageBoxIcon.Warning);
                txtAmount.Focus();
                return;
            }

            StoreDto newStore = new StoreDto()
            {
                MaterialId   = materialDto.Id,
                Amount       = float.Parse(txtAmount.Text),
                StoredDate   = DateUtil.GetDateTime(txtStoreDate.Text),
                StoredStatus = importExportType.code,
                Reason       = txtReason.Text,
                StoredBy     = "SYSTEM",
                MaterialName = materialDto.Name,
                UnitName     = txtUnit.Text
            };

            listStoreDto.Add(newStore);

            dgvStores.Rows.Clear();

            foreach (StoreDto material in listStoreDto)
            {
                AddOneRow(material);
            }

            txtAmount.Text = "";
            materialComboBox.Focus();
        }
예제 #30
0
        public static Hashtable AllValues(DataRow dataRow, List <string> colNames)
        {
            int       length    = colNames.Count + 1;
            Hashtable hashtable = new Hashtable();

            try
            {
                for (int key = 2; key <= length; key++)
                {
                    hashtable.Add(key, dataRow[colNames[key - 2]]);
                }
                return(hashtable);
            }
            catch (Exception exception)
            {
                MMessageBox.Show(null, exception.Message);
                return(new Hashtable());
            }
        }