private void LoadBillsServices(List <ServiceMapped> services = null)
        {
            LazyWorker <ServiceMapped> .LoadAllToGridView
            (
                ServiceListGridView,
                new string[]
            {
                "Id", "ServiceName", "Price", "RoomId",
                "BelongToRoom", "Count", "BillId"
            },
                services ?? LessLazyWorker.GetMappedServiceByBill(currentBill.Id)
            );

            ServiceListGridView.Columns["Id"].Visible           = false;
            ServiceListGridView.Columns["RoomId"].Visible       = false;
            ServiceListGridView.Columns["BillId"].Visible       = false;
            ServiceListGridView.Columns["Filter"].Visible       = false;
            ServiceListGridView.Columns["BillDetailId"].Visible = false;

            ServiceListGridView.Columns["ServiceName"].HeaderText  = "Tên dịch vụ";
            ServiceListGridView.Columns["Price"].HeaderText        = "Giá";
            ServiceListGridView.Columns["Count"].HeaderText        = "Số lượng";
            ServiceListGridView.Columns["BelongToRoom"].HeaderText = "Thuộc về phòng";

            ServiceListGridView.Columns["ServiceName"].Width             = 150;
            ServiceListGridView.Columns["Price"].DefaultCellStyle.Format = "### ### ### ###";
            ServiceListGridView.Columns["Price"].AutoSizeMode
                = DataGridViewAutoSizeColumnMode.AllCells;
            ServiceListGridView.Columns["Count"].Width = 100;
            ServiceListGridView.Columns["BelongToRoom"].AutoSizeMode
                = DataGridViewAutoSizeColumnMode.AllCells;
        }
Exemple #2
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(UsernameTextbox.Text) ||
                string.IsNullOrEmpty(PasswordTextbox.Text))
            {
                MessageBox.Show("Tên đăng nhập hoặc mật khẩu bị để trống. Xin hãy kiểm tra lại.");
                return;
            }

            string username        = UsernameTextbox.Text,
                   hashed_password = StringUtilities.MD5Hash(PasswordTextbox.Text);

            Employee emp = LessLazyWorker.GetEmployee(username, hashed_password);

            if (emp != null && emp.Id > 0)
            {
                Hide();
                form.SetCurrentEmployee(emp);
                form.Show(this);
            }
            else
            {
                MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu. Xin hãy kiểm tra lại.");
            }
        }
        private void NewBillButton_Click(object sender, EventArgs e)
        {
            BillModel bill = new BillModel()
            {
                CustomerId  = (CustomerComboBox.SelectedIndex == 0 ? null : (int?)CustomerComboBox.SelectedIndex),
                EmployeeId  = (EmployeeComboBox.SelectedIndex == 0 ? null : (int?)EmployeeComboBox.SelectedIndex),
                CreatingDay = DateTime.Today.Date
            };

            bill.Id = LazyWorker <BillModel> .Insert(bill);

            SetCurrentBill(LessLazyWorker.BillModelToBillDisplay(bill));
        }
Exemple #4
0
        private void LoadAllServices()
        {
            //
            var list = LessLazyWorker.GetAllServices();

            list.Insert(0, new ServiceDisplay());
            ServiceComboBox.DataSource = list;

            ServiceComboBox.ValueMember   = "Id";
            ServiceComboBox.DisplayMember = "DisplayString";

            TotalPriceNumericUpDown.Value
                = LessLazyWorker.TotalPriceOfBill(currentBill.Id);
        }
        public void SetCurrentBill(BillDisplay bill)
        {
            currentBill = bill;

            LoadAllServices();
            LoadAllCustomers();
            LoadAllEmployees();

            if (bill.Id != 0)
            {
                LoadBillsServices();
                currentDetails = LessLazyWorker.GetBillDetails(currentBill.Id);

                CustomerComboBox.SelectedValue = bill.Customer_.Id;
                EmployeeComboBox.SelectedValue = bill.Employee_.Id;

                SaveBillButton.Enabled           =
                    DeleteBillButton.Enabled     =
                        ExportBillButton.Enabled =
                            true;

                AddServiceButton.Enabled            =
                    SaveServiceButton.Enabled       =
                        RemoveServiceButton.Enabled =
                            true;
            }
            else
            {
                LoadBillsServices(new List <ServiceMapped>());
                currentDetails = new List <BillDetail>();

                CustomerComboBox.SelectedIndex = 0;
                EmployeeComboBox.SelectedIndex = 0;

                SaveBillButton.Enabled           =
                    DeleteBillButton.Enabled     =
                        ExportBillButton.Enabled =
                            false;

                AddServiceButton.Enabled            =
                    SaveServiceButton.Enabled       =
                        RemoveServiceButton.Enabled =
                            false;
            }
        }
Exemple #6
0
        //one same function to every DataGridView
        public static void LoadAllToGridView
        (
            DataGridView gridView,
            string[] columnNames,      //order
            List <T> customList = null //if the list is null then use GetAll()
        )
        {
            var list  = customList ?? GetAll();
            var table = ListToDataTable(list);

            LessLazyWorker.SetColumnsOrder(table, columnNames);
            table.Columns.Add("Filter");
            foreach (DataRow row in table.Rows)
            {
                row["Filter"] = DataRowToObject(row).ToString();
            }

            gridView.DataSource = table;
        }
        private void LoadAllBills()
        {
            LazyWorker <BillDisplay> .LoadAllToGridView
            (
                BillGridView,
                new string[] { "Id", "Customer_", "Employee_", "CreatingDay" },
                LessLazyWorker.GetAllBills()
            );

            DataTable table = (DataTable)BillGridView.DataSource;

            table.Columns.Add("Customer");
            table.Columns.Add("Employee");
            LessLazyWorker.SetColumnsOrder(table,
                                           new string[] { "Customer", "Employee", "CreatingDay", "TotalPrice" });

            foreach (DataRow row in table.Rows)
            {
                BillDisplay bill = LazyWorker <BillDisplay> .DataRowToObject(row);

                row["Customer"] = bill.Customer_ != null ? bill.Customer_.FullName : "";
                row["Employee"] = bill.Employee_ != null ? bill.Employee_.FullName : "";
            }

            BillGridView.DataSource = table;

            BillGridView.Columns["Id"].Visible        = false;
            BillGridView.Columns["Filter"].Visible    = false;
            BillGridView.Columns["Customer_"].Visible = false;
            BillGridView.Columns["Employee_"].Visible = false;

            BillGridView.Columns["CreatingDay"].HeaderText             = "Ngày khởi tạo";
            BillGridView.Columns["Customer"].HeaderText                = "Tên khách";
            BillGridView.Columns["Employee"].HeaderText                = "Tạo bởi";
            BillGridView.Columns["TotalPrice"].HeaderText              = "Tổng tiền";
            BillGridView.Columns["TotalPrice"].DefaultCellStyle.Format = "### ### ### ###";
        }
        private void LoadAllServices()
        {
            LazyWorker <ServiceDisplay> .LoadAllToGridView
            (
                ServiceGridView,
                new string[] { "Id", "ServiceName", "Price", "BelongToRoom" },
                LessLazyWorker.GetAllServices()
            );

            ServiceGridView.Columns["Id"].Visible = false;

            ServiceGridView.Columns["ServiceName"].HeaderText = "Tên dịch vụ";
            ServiceGridView.Columns["ServiceName"].Width      = 150;

            ServiceGridView.Columns["Price"].HeaderText = "Giá dịch vụ";
            ServiceGridView.Columns["Price"].AutoSizeMode
                = DataGridViewAutoSizeColumnMode.AllCells;
            ServiceGridView.Columns["Price"].DefaultCellStyle.Format = "### ### ### ###";

            ServiceGridView.Columns["BelongToRoom"].HeaderText = "Thuộc về phòng";
            ServiceGridView.Columns["BelongToRoom"].Width      = 150;

            ServiceGridView.Columns["Filter"].Visible = false;
        }