Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!checkData())
            {
                return;
            }
            try
            {
                if (m_IsAdd)
                {
                    String _user = createUserName(txtStaffName.Text, dateBirthDay.DateTime.ToString());
                    String _pass = Utils.GetMD5("123456789");

                    staffObject = new DTOStaff("NV000000", txtStaffName.Text, cmbStaffGender.Text, dateBirthDay.DateTime, txtStaffAddress.Text, txtStaffPhone.Text, txtStaffEmail.Text,
                                               dateToWork.DateTime, lkStaffCharge.EditValue.ToString(), _user, _pass);

                    if (staffBUS.InsertStaff(staffObject))
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
                else
                {
                    staffObject = new DTOStaff(txtStaffId.Text, txtStaffName.Text, cmbStaffGender.Text, dateBirthDay.DateTime,
                                               txtStaffAddress.Text, txtStaffPhone.Text, txtStaffEmail.Text,
                                               dateToWork.DateTime, lkStaffCharge.EditValue.ToString(), null, null);

                    if (staffBUS.UpdateStaffNoUsernamePassword(staffObject))
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!\nVui lòng thiết lập quyền truy cập hệ thống cho nhân viên '" + staffObject.Name + "'!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
            }
            catch (System.Exception)
            {
                XtraCustomMessageBox.Show("Lưu dữ liệu thất bại!", "Lỗi", true, 4);
            }
            finally
            {
                updateEnableButtonAndResetValueOfControl(ref btnSave);
            }
        }
Esempio n. 2
0
        private void SaveDataToDatabase()
        {
            if (!checkData())
            {
                return;
            }
            try
            {
                if (m_IsAdd)
                {
                    String  roomTypeName   = Utils.standardNamePerson(txtRoomTypeName.Text);
                    decimal roomTypePrices = Math.Round(spPrices.Value);
                    roomTypeObject = new DTORoomType("LP00000000", roomTypeName, roomTypePrices);

                    if (roomTypeBUS.InsertRoomType(roomTypeObject))
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
                else
                {
                    String  roomTypeName   = Utils.standardNamePerson(txtRoomTypeName.Text);
                    decimal roomTypePrices = Math.Round(spPrices.Value);
                    roomTypeObject = new DTORoomType(txtRoomTypeId.Text, roomTypeName, roomTypePrices);

                    if (roomTypeBUS.UpdateRoomType(roomTypeObject))
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
            }
            catch (System.Exception ex)
            {
                XtraCustomMessageBox.Show(ex.ToString(), "Lỗi", true, 3);
            }
            finally
            {
                updateEnableButtonAndResetValueOfControl(ref btnSave);
            }
        }
Esempio n. 3
0
 private void dateTo_EditValueChanged(object sender, EventArgs e)
 {
     if (dateTo.DateTime > DateTime.Now)
     {
         XtraCustomMessageBox.Show("Ngày kết thúc không được lớn hơn ngày hiện tại!", "Thông báo", true, 2);
         dateTo.EditValue = null;
     }
     if (!dateFrom.Text.Equals(""))
     {
         if (dateFrom.DateTime > dateTo.DateTime)
         {
             XtraCustomMessageBox.Show("Ngày kết thúc không được nhỏ hơn ngày bắt đầu!", "Thông báo", true, 2);
             dateFrom.EditValue = null;
         }
     }
 }
Esempio n. 4
0
 private void btnView_Click(object sender, EventArgs e)
 {
     if (!CheckData())
     {
         XtraCustomMessageBox.Show("Vui lòng chọn thời gian lập báo cáo!", "Thông báo", true, 2);
     }
     else
     {
         //
         ReportByDate();
         //
         revenueReport.DataSource      = revenueDataTable;
         docRevenueView.PrintingSystem = revenueReport.PrintingSystem;
         revenueReport.CreateDocument();
     }
 }
Esempio n. 5
0
        private void SaveDataToDatabase()
        {
            if (!checkData())
            {
                return;
            }
            try
            {
                if (m_IsAdd)
                {
                    String unitName = Utils.standardNamePerson(txtUnitName.Text);
                    unitObject = new DTOUnit("DOV0000000", unitName);

                    if (unitBUS.InsertUnit(unitObject))
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
                else
                {
                    String unitName = Utils.standardNamePerson(txtUnitName.Text);
                    unitObject = new DTOUnit(txtUnitId.Text, unitName);

                    if (unitBUS.UpdateUnit(unitObject))
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
            }
            catch (System.Exception ex)
            {
                XtraCustomMessageBox.Show(ex.ToString(), "Lỗi", true, 3);
            }
            finally
            {
                updateEnableButtonAndResetValueOfControl(ref btnSave);
            }
        }
Esempio n. 6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!checkData())
            {
                return;
            }
            try
            {
                if (m_IsAdd)
                {
                    customerObject = new DTOCustomer("KH000000", txtCustomerName.Text, cmbCustomerGender.Text, dateBirthDay.DateTime,
                                                     txtCustomerAddress.Text, txtCustomerPhone.Text, txtCustomerEmail.Text, txtCMND.Text);

                    if (customerBUS.InsertCustomer(customerObject))
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
                else
                {
                    customerObject = new DTOCustomer(txtCustomerId.Text, txtCustomerName.Text, cmbCustomerGender.Text, dateBirthDay.DateTime,
                                                     txtCustomerAddress.Text, txtCustomerPhone.Text, txtCustomerEmail.Text, txtCMND.Text);

                    if (customerBUS.UpdateCustomer(customerObject))
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
            }
            catch (System.Exception)
            {
                XtraCustomMessageBox.Show("Lưu dữ liệu thất bại!", "Lỗi", true, 4);
            }
            finally
            {
                updateEnableButtonAndResetValueOfControl(ref btnSave);
            }
        }
Esempio n. 7
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (unitMulitiSelect.Selection.Count == 0)
     {
         XtraCustomMessageBox.Show("Chưa có dòng dữ liệu nào được chọn!", "Thông báo", true, 1);
         return;
     }
     try
     {
         System.Collections.ArrayList _listunitObjectInDelibility = new System.Collections.ArrayList();
         foreach (object _rowObjectItem in unitMulitiSelect.Selection)
         {
             grdvListUnit.FocusedRowHandle -= 1;
             DataRowView _rowObjectDetail = _rowObjectItem as DataRowView;
             unitObject = new DTOUnit(_rowObjectDetail.Row["UnitID"].ToString(), _rowObjectDetail.Row["UnitName"].ToString());
             if (!unitBUS.DeleteUnit(unitObject.UnitID))
             {
                 _listunitObjectInDelibility.Add(_rowObjectDetail.Row["UnitID"]);
             }
         }
         String _erroContent = "Không thể xóa thông tin các thế loại sách có mã số: \n";
         if (_listunitObjectInDelibility.Count != 0)
         {
             foreach (var item in _listunitObjectInDelibility)
             {
                 _erroContent += item.ToString() + "\n";
             }
             XtraCustomMessageBox.Show(_erroContent, "Lỗi", true, 4);
         }
         else
         {
             XtraCustomMessageBox.Show("Xóa dữ liệu thành công", "Thông báo", true, 1);
         }
     }
     catch (System.Exception)
     {
         XtraCustomMessageBox.Show("Xóa dữ liệu thất bại", "Lỗi", true, 4);
     }
     finally
     {
         updateEnableButtonAndResetValueOfControl(ref btnDelete);
     }
 }
Esempio n. 8
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (customerMultiSelect.Selection.Count == 0)
     {
         XtraCustomMessageBox.Show("Chưa có dòng dữ liệu nào được chọn!", "Cảnh báo", true, 3);
         return;
     }
     try
     {
         ArrayList _listCustomerId = new ArrayList();
         grdvListCustomer.FocusedRowHandle -= 1;
         foreach (DataRowView _rowData in customerMultiSelect.Selection)
         {
             customerObject            = new DTOCustomer();
             customerObject.CustomerID = _rowData["CustomerID"].ToString();
             if (!customerBUS.DeleteCustomer(customerObject.CustomerID))
             {
                 _listCustomerId.Add(_rowData["CustomerID"]);
             }
         }
         if (_listCustomerId.Count != 0)
         {
             String _erroContent = "Không thể xóa các khách hàng có mã: \n";
             foreach (var item in _listCustomerId)
             {
                 _erroContent += item.ToString() + "\n";
             }
             XtraCustomMessageBox.Show(_erroContent, "Lỗi", true, 4);
         }
         else
         {
             XtraCustomMessageBox.Show("Xóa dữ liệu thành công!", "Thông báo", true, 1);
         }
     }
     catch (System.Exception)
     {
         XtraCustomMessageBox.Show("Xóa dữ liệu thất bại", "Lỗi", true, 4);
     }
     finally
     {
         updateEnableButtonAndResetValueOfControl(ref btnDelete);
     }
 }
Esempio n. 9
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            roomMulitiSelect.ClearSelection();
            roomResultDataTable = roomBUS.GetAllRoomByDateFromTo(dateStart.DateTime, dateEnd.DateTime);
            if (roomResultDataTable == null || roomResultDataTable.Rows.Count == 0)
            {
                XtraCustomMessageBox.Show("Không tìm thấy dữ liệu nào!", "Thông báo", true, 1);
                return;
            }
            string[] roomTypeIDs = (chkCmbRoomTypeName.EditValue.ToString()).Split(',');
            if (roomTypeIDs.Count() == 0)
            {
                XtraCustomMessageBox.Show("Bạn chưa chọn loại phòng!", "Thông báo", true, 1);
                return;
            }
            string expression = "RoomTypeID IN(";

            for (int i = 0; i < roomTypeIDs.Count(); ++i)
            {
                expression += "'" + roomTypeIDs[i].Trim() + "'";
                if (i < roomTypeIDs.Count() - 1)
                {
                    expression += ",";
                }
            }
            expression += ")";
            DataRow[] foundRows;
            foundRows = roomResultDataTable.Select(expression);
            //  DataRow newRow = roomResultDataTable.NewRow();
            roomResultDataTableClone = roomResultDataTableClone.Clone();
            foreach (DataRow row in foundRows)
            {
                if (!this.checkRowValue(ref roomSelectsDataTable, row))
                {
                    DataRow newRow = this.copyToRow(row, ref roomResultDataTableClone, false);
                    roomResultDataTableClone.Rows.Add(newRow);
                }
            }
            roomResultDataTableClone       = DataTableCustomize.AutoNumberedTable(roomResultDataTableClone);
            grdSearchRoomResult.DataSource = roomResultDataTableClone;
        }
Esempio n. 10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            staffDTO          = frmHomePage.staffLogin;
            staffDTO.Name     = Utils.standardNamePerson(txtStaffName.Text.Trim());
            staffDTO.Phone    = txtStaffPhone.Text.Trim();
            staffDTO.Email    = txtStaffEmail.Text.Trim();
            staffDTO.Birthday = dateBirthDay.DateTime;
            staffDTO.Address  = Utils.standardNamePerson(txtStaffAddress.Text.Trim());
            staffDTO.Gender   = cmbStaffGender.Text.Trim();

            if (staffBUS.UpdateStaffNoUsernamePassword(staffDTO))
            {
                XtraCustomMessageBox.Show("Cập nhật thành công!", "Thông báo", false, 1);
                frmHomePage.staffLogin = staffDTO;
                InitDisplay(false);
                InitfrmInfoStaff();
            }
            else
            {
                XtraCustomMessageBox.Show("Cập nhật thất bại!", "Lỗi", false, 4);
            }
        }
Esempio n. 11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ruleObject1 = new DTORule("1", "DoTuoiNhanVienToiThieu", spMinimumAge.Value.ToString());
            ruleObject2 = new DTORule("2", "DoTuoiNhanVienToiDa", spMaximumAge.Value.ToString());
            //
            ruleObject3 = new DTORule("3", "ThueTNDN", spTax.Value.ToString());
            //
            ruleObject4  = new DTORule("4", "TenKhachSan", txtNameSystem.Text.Trim());
            ruleObject5  = new DTORule("5", "DiaChi", txtAddress.Text.Trim());
            ruleObject6  = new DTORule("6", "Email", txtEmail.Text.Trim());
            ruleObject7  = new DTORule("7", "DienThoai", txtPhone.Text.Trim());
            ruleObject8  = new DTORule("8", "Fax", txtFaxNumber.Text.Trim());
            ruleObject9  = new DTORule("9", "MaSoThue", txtTaxId.Text.Trim());
            ruleObject10 = new DTORule("10", "Website", txtWebsite.Text.Trim());

            if (ruleBUS.UpdateRule(ruleObject1) && ruleBUS.UpdateRule(ruleObject2) &&
                ruleBUS.UpdateRule(ruleObject3) && ruleBUS.UpdateRule(ruleObject4) &&
                ruleBUS.UpdateRule(ruleObject5) && ruleBUS.UpdateRule(ruleObject6) &&
                ruleBUS.UpdateRule(ruleObject7) && ruleBUS.UpdateRule(ruleObject8) &&
                ruleBUS.UpdateRule(ruleObject9) && ruleBUS.UpdateRule(ruleObject10))
            {
                XtraCustomMessageBox.Show("Cập nhật dữ liệu thành công!", "Thông báo", true, 1);
            }
            else
            {
                XtraCustomMessageBox.Show("Cập nhật dữ liệu thất bại!", "Lỗi", true, 4);
            }

            //
            btnCancelUpdate.Enabled = false;
            btnCancelUpdate.Visible = false;
            btnUpdate.Visible       = true;
            btnUpdate.Enabled       = true;
            btnSave.Enabled         = false;
            //
            btnCancelUpdate_Click(null, null);
        }
Esempio n. 12
0
 private void bbtnLogout_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (xtraTabbedMdiManagerMenu.FloatForms.Count != 0)
     {
         XtraCustomMessageBox.Show("Vui lòng đóng tất cả các của sổ trước khi đăng xuất!", "Thông báo", false, 1);
     }
     else
     {
         DialogResult rs = XtraCustomMessageBox.Show("Bạn có muốn đăng xuất khỏi hệ thông?", "Thông báo", false, 2);
         if (rs == DialogResult.Yes)
         {
             new frmLogin().Show();
             staffLogin        = null;
             rolePermissionObj = null;
             //
             this.Dispose();
             this.Close();
         }
         else
         {
             return;
         }
     }
 }
Esempio n. 13
0
        private DataRow copyToRow(DataRow sourceRow, ref DataTable destDataTable, bool isListRoomTable)
        {
            DataRow newRow = destDataTable.NewRow();

            newRow["RoomID"]       = sourceRow["RoomID"];
            newRow["RoomName"]     = sourceRow["RoomName"];
            newRow["RoomTypeName"] = sourceRow["RoomTypeName"];
            newRow["NumberOfBeds"] = sourceRow["NumberOfBeds"];
            newRow["StatusName"]   = sourceRow["StatusName"];
            newRow["Price"]        = sourceRow["Price"];
            if (isListRoomTable)
            {
                newRow["StartDate"] = dateStart.DateTime;
                newRow["EndDate"]   = dateEnd.DateTime;
                double dateDiff = (dateEnd.DateTime - dateStart.DateTime).Days;
                object price    = newRow["Price"];
                try
                {
                    if (price != null && price.ToString().Trim() != "")
                    {
                        newRow["Monetized"] = ((dateDiff == 0) ? 1 : dateDiff + 1) * int.Parse(price.ToString().Trim());
                    }
                    else
                    {
                        newRow["Monetized"] = 0;
                    }
                }
                catch (Exception)
                {
                    newRow["Monetized"] = 0;
                    XtraCustomMessageBox.Show("Thông báo", "Bạn chưa thiết lập giá phòng!", true, 4);
                    throw;
                }
            }
            return(newRow);
        }
Esempio n. 14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            updateEnableButtonAndResetValueOfControl(ref btnSave);
            try
            {
                serviceDetailBUS.DeleteAllServiceDetailByOrderID(lblOrderValue.Text.Trim());
                int Total = 0;
                for (int i = 0; i < listServiceDetailObject.Count; i++)
                {
                    listServiceDetailObject[i].ServicesDetailID = "DVC0000000";
                    listServiceDetailObject[i].OrderDetailID    = lblOrderValue.Text.Trim();
                    if (!serviceDetailBUS.InsertServiceDetail(listServiceDetailObject[i]))
                    {
                        XtraCustomMessageBox.Show("Thêm thất bại dịch vụ có mã: " + listServiceDetailObject[i].ServicesID, "Lỗi", true, 1);
                    }
                    else
                    {
                        Total += listServiceDetailObject[i].Total;
                    }
                }

                orderDetailBUS.UpdateServiceMoneyOrderDetailById(lblOrderValue.Text.Trim(), Total);
                orderBUS.UpdateTotalOrderById(orderDetailBUS.GetOrderIDByOrderDetailID(lblOrderValue.Text.Trim()).Trim());
                orderDetailDataTable   = orderDetailBUS.GetAllOrderDetailFromNow();
                gvRoomOrder.DataSource = orderDetailDataTable;
                //Cập nhật controls của form
                updateEnableButtonAndResetValueOfControl(ref btnSave);

                XtraCustomMessageBox.Show("Ghi dữ liệu thành công!", "Thông báo", true, 1);
                listServiceDetailObject.Clear();
            }
            catch (System.Exception)
            {
                XtraCustomMessageBox.Show("Không thể ghi dữ liệu!", "Lỗi", true, 4);
            }
        }
Esempio n. 15
0
        private void SaveDataToDatabase()
        {
            if (!checkData())
            {
                return;
            }
            if (roomSelectsDataTable.Rows.Count <= 0)
            {
                XtraCustomMessageBox.Show("Bạn chưa chọn phòng!", "Thông báo", false, 4);
                return;
            }
            try
            {
                if (m_IsAdd)
                {
                    String   customerID     = lkCustomer.EditValue.ToString();
                    String   staffID        = "NV000001";//Utils.standardNamePerson(frmHomePage.staffLogin.StaffID);
                    DateTime orderOfDate    = DateTime.Now;
                    int      numberOfPeople = (int)spinTotalPeople.Value;
                    int      estimate       = (int)spintotalEstimate.Value;
                    int      deposit        = (int)spinDeposit.Value;
                    int      total          = 0;
                    int      orderStatus    = (int)ORDERSTATUS.UNPAID;
                    dtoOrder = new DTOOrder("DP0000000",
                                            customerID,
                                            staffID,
                                            orderOfDate,
                                            numberOfPeople,
                                            estimate,
                                            deposit,
                                            total,
                                            orderStatus);

                    if (orderBUS.InsertOrder(dtoOrder))
                    {
                        //XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                        String   orderMaxID     = orderBUS.GetOrderMaxID();
                        DateTime dateStartValue = dateStart.DateTime;
                        DateTime dateEndValue   = dateEnd.DateTime;
                        String   roomID         = "";
                        int      estimateValue  = 0;
                        int      serviceMoney   = 0;
                        foreach (DataRow row in roomSelectsDataTable.Rows)
                        {
                            roomID = row["RoomID"].ToString();
                            try
                            {
                                estimateValue = int.Parse(row["Monetized"].ToString().Trim());
                            }
                            catch (Exception)
                            {
                                estimateValue = 0;
                                throw;
                            }
                            serviceMoney = 0;

                            DTOOrderDetail dtoOderDetail = new DTOOrderDetail("CDP0000000",
                                                                              orderMaxID,
                                                                              roomID,
                                                                              dateStartValue,
                                                                              dateEndValue,
                                                                              estimateValue,
                                                                              serviceMoney);
                            if (!orderDetailBUS.InsertOrderDetails(dtoOderDetail))
                            {
                                //Khi them chi tiet that bai
                                //Xoa du lieu hien tai
                                orderDetailBUS.DeleteOrderDetails(orderMaxID);
                                orderBUS.DeteleOrder(orderMaxID);
                                XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);

                                return;
                            }
                        }
                        //Update button view
                        btnChangeToView.Enabled = true;
                        XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
                else
                {
                    String   orderID        = "";
                    String   customerID     = lkCustomer.EditValue.ToString();
                    String   staffID        = "NV000001";// frmHomePage.staffLogin.StaffID;
                    DateTime orderOfDate    = DateTime.Now;
                    int      numberOfPeople = (int)spinTotalPeople.Value;
                    int      estimate       = (int)spintotalEstimate.Value;
                    int      deposit        = (int)spinDeposit.Value;
                    int      total          = estimate;
                    int      orderStatus    = (int)ORDERSTATUS.UNPAID;
                    dtoOrder = new DTOOrder(orderID,
                                            customerID,
                                            staffID,
                                            orderOfDate,
                                            numberOfPeople,
                                            estimate,
                                            deposit,
                                            total,
                                            orderStatus);

                    if (orderBUS.UpdateOrder(dtoOrder))
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thành công!", "Thông báo", true, 1);
                    }
                    else
                    {
                        XtraCustomMessageBox.Show("Thêm dữ liệu thất bại!", "Lỗi", true, 4);
                    }
                }
            }
            catch (System.Exception ex)
            {
                XtraCustomMessageBox.Show(ex.ToString(), "Lỗi", true, 3);
            }
            finally
            {
                updateEnableButtonAndResetValueOfControl(ref btnSave);
            }
        }