private void LoadAllCustomer()
        {
            LazyWorker <Customer> .LoadAllToGridView
            (
                CustomerGridView,
                new string[]
                { "Id", "FullName", "DateOfBirth", "Sex", "RealLifeIdNumber" }
            );

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

            CustomerGridView.Columns["FullName"].Width      = 100;
            CustomerGridView.Columns["FullName"].HeaderText = "Họ tên";

            CustomerGridView.Columns["DateOfBirth"].AutoSizeMode
                = DataGridViewAutoSizeColumnMode.AllCells;
            CustomerGridView.Columns["DateOfBirth"].HeaderText = "Ngày sinh";

            CustomerGridView.Columns["Sex"].Visible = false;

            CustomerGridView.Columns["RealLifeIdNumber"].Width      = 100;
            CustomerGridView.Columns["RealLifeIdNumber"].HeaderText = "Số CMND";

            CustomerGridView.Columns["Filter"].Visible = false;
        }
        private void LoadAllRooms(int index = 0)
        {
            var list = LazyWorker <Room> .GetAll();

            list.Insert(0, new Room()
            {
                Id       = 0,
                RoomName = ""
            });

            RoomComboBox.DataSource    = list;
            RoomComboBox.DisplayMember = "RoomName";
            RoomComboBox.ValueMember   = "Id";

            if (index < 0)
            {
                index = 0;
            }
            else if (index >= RoomComboBox.Items.Count)
            {
                index = RoomComboBox.Items.Count - 1;
            }

            RoomComboBox.SelectedIndex = index;
        }
        private string CurrentBillToString()
        {
            string NewLine     = Environment.NewLine,
                   lazyNewLine = Environment.NewLine + Environment.NewLine;
            string result      = "Hóa đơn tính tiền" + lazyNewLine;

            result += "Thời gian xuất: " + DateTime.Now + NewLine;
            result += "------------------------------" + NewLine;
            foreach (DataRow row in ((DataTable)ServiceListGridView.DataSource).Rows)
            {
                var service = LazyWorker <ServiceMapped> .DataRowToObject(row);

                result += service.ServiceName + ": " +
                          StringUtilities.LazyFormat(service.Price) + " x " +
                          service.Count + " = " +
                          StringUtilities.LazyFormat(service.Price * service.Count) +
                          NewLine;
            }
            result += "------------------------------" + NewLine;
            result += "Tổng tiền: " + StringUtilities.LazyFormat(currentBill.TotalPrice) + lazyNewLine;
            result += "Tên khách hàng: " + currentBill.Customer_.FullName + lazyNewLine;
            result += "Nhân viên tạo hóa đơn: " + currentBill.Employee_.FullName + lazyNewLine;

            return(result);
        }
        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;
        }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            LazyWorker <Employee> .Update(FilledDataToEmployee());

            LoadAllEmployees();
            MessageBox.Show("Dữ liệu đã được cập nhật thành công!");
        }
        private void NewButton_Click(object sender, EventArgs e)
        {
            string message = "";

            if (string.IsNullOrEmpty(UsernameTextbox.Text))
            {
                message += "– Tên đăng nhập bị bỏ trống." + Environment.NewLine;
            }
            if (string.IsNullOrEmpty(PasswordTextbox.Text))
            {
                message += "– Mật khẩu bị bỏ trống." + Environment.NewLine;
            }
            if (string.IsNullOrEmpty(FullNameTextbox.Text))
            {
                message += "– Họ tên bị bỏ trống." + Environment.NewLine;
            }

            if (!string.IsNullOrEmpty(message))
            {
                message = "Tạo nhân viên mới thất bại vì (những) lý do sau:" + Environment.NewLine + message;
            }
            else
            {
                IdNumericUpdown.Value
                    = LazyWorker <Employee> .Insert(FilledDataToEmployee());

                message = "Tạo mới thành công!";
                LoadAllEmployees();
            }
            MessageBox.Show(message);
        }
        private void LoadEmployee(Employee emp)
        {
            this.emp = emp;
            this.emp = LazyWorker <Employee> .Get(emp.Id);

            UsernameTextbox.Text = this.emp.Username;
        }
 private void SaveButton_Click(object sender, EventArgs e)
 {
     if (LazyWorker <Customer> .Update(FilledDataToCustomer()))
     {
         LoadAllCustomer();
         FormUtilities.NotifySuccess();
     }
 }
 private void SaveRoomButton_Click(object sender, EventArgs e)
 {
     if (LazyWorker <Room> .Update(FilledDataToRoom()))
     {
         FormUtilities.NotifySuccess();
         LoadAllRooms(RoomComboBox.SelectedIndex);
     }
 }
        private void NewRoomButton_Click(object sender, EventArgs e)
        {
            RoomIdNumericUpDown.Value
                = LazyWorker <Room> .Insert(FilledDataToRoom());

            LoadAllRooms(Int32.MaxValue);
            FormUtilities.NotifySuccess();
        }
        private void DeleteRoomButton_Click(object sender, EventArgs e)
        {
            if (FormUtilities.ConfirmDeletion())
            {
                LazyWorker <Room> .Delete(FilledDataToRoom());

                LoadAllRooms();
            }
        }
Exemple #12
0
        private void LoadAllCustomers()
        {
            var list = LazyWorker <Customer> .GetAll();

            list.Insert(0, new Customer());

            CustomerComboBox.DataSource    = list;
            CustomerComboBox.DisplayMember = "FullName";
            CustomerComboBox.ValueMember   = "Id";
        }
 public static BillDisplay BillModelToBillDisplay(BillModel bill)
 {
     return(new BillDisplay()
     {
         Id = bill.Id,
         Customer_ = LazyWorker <Customer> .Get(bill.CustomerId != null?bill.CustomerId.Value : 0),
         Employee_ = LazyWorker <Employee> .Get(bill.EmployeeId != null?bill.EmployeeId.Value : 0),
         CreatingDay = bill.CreatingDay
     });
 }
 private void EmployeeGridView_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     LazyWorker <Employee> .LoadOneFromGridView
     (
         EmployeeGridView,
         LoadOneEmployee,
         SaveButton,
         DeleteButton
     );
 }
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            if (FormUtilities.ConfirmDeletion())
            {
                LazyWorker <Employee> .Delete(FilledDataToEmployee());

                LoadAllEmployees();
                LoadOneEmployee(new Employee());
            }
        }
Exemple #16
0
 private void ServiceListGridView_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     LazyWorker <ServiceMapped> .LoadOneFromGridView
     (
         ServiceListGridView,
         LoadOneService,
         SaveServiceButton,
         RemoveServiceButton
     );
 }
 private void BillGridView_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     LazyWorker <BillDisplay> .LoadOneFromGridView
     (
         BillGridView,
         LoadOneBill,
         EditButton,
         DeleteButton
     );
 }
Exemple #18
0
        private void LoadAllEmployees()
        {
            var list = LazyWorker <Employee> .GetAll();

            list.Insert(0, new Employee());

            EmployeeComboBox.DataSource    = list;
            EmployeeComboBox.DisplayMember = "Username";
            EmployeeComboBox.ValueMember   = "Id";
        }
 private void CustomerGridView_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     LazyWorker <Customer> .LoadOneFromGridView
     (
         CustomerGridView,
         LoadOneCustomer,
         SaveButton,
         DeleteButton
     );
 }
 private void DeleteServiceButton_Click(object sender, EventArgs e)
 {
     if (FormUtilities.ConfirmDeletion() &&
         LazyWorker <ServiceModel> .Delete(FilledDataToService()))
     {
         LoadAllRooms();
         ResetServiceButton_Click(sender, e);
         FormUtilities.NotifySuccess();
     }
 }
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            if (FormUtilities.ConfirmDeletion())
            {
                LazyWorker <Customer> .Delete(FilledDataToCustomer());

                LoadAllCustomer();
                ResetButton_Click(sender, e);
            }
        }
        private void NewServiceButton_Click(object sender, EventArgs e)
        {
            ServiceIdNumericUpDown.Value = LazyWorker <ServiceModel> .Insert(FilledDataToService());

            LoadAllServices();
            FormUtilities.SetRowIndex(ServiceGridView);
            SaveServiceButton.Enabled   = true;
            DeleteServiceButton.Enabled = true;
            FormUtilities.NotifySuccess();
        }
        private void SaveServiceButton_Click(object sender, EventArgs e)
        {
            if (LazyWorker <ServiceModel> .Update(FilledDataToService()))
            {
                int index = ServiceGridView.SelectedRows[0].Index;
                LoadAllServices();
                FormUtilities.SetRowIndex(ServiceGridView, index);

                FormUtilities.NotifySuccess();
            }
        }
 private void NewButton_Click(object sender, EventArgs e)
 {
     if
     (
         (IdNumericUpdown.Value
              = LazyWorker <Customer> .Insert(FilledDataToCustomer())) > 0
     )
     {
         LoadAllCustomer();
         FormUtilities.NotifySuccess();
     }
 }
        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));
        }
        private void ServicesGridView_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            if ((ServiceGridView.SelectedRows.Count > 0 && ServiceGridView.SelectedRows[0] != null) ||
                ServiceGridView.Rows.Count == 1)
            {
                DataRowView rowView = (ServiceGridView.Rows.Count == 1)
                    ? (ServiceGridView.Rows[0].DataBoundItem as DataRowView)
                    : (ServiceGridView.SelectedRows[0].DataBoundItem as DataRowView);

                LoadOneService(LazyWorker <ServiceDisplay> .DataRowToObject(rowView.Row));

                SaveServiceButton.Enabled   = true;
                DeleteServiceButton.Enabled = true;
            }
        }
        public static List <ServiceMapped> GetMappedServiceByBill(int billId)
        {
            var list = connection.Query <ServiceMapped>
                           (@"select Services.Id, Services.Price, Services.RoomId, Services.ServiceName, 
                BillDetails.Count, BillDetails.BillId, BillDetails.Id as BillDetailId
                from BillDetails join Services on BillDetails.ServiceId = Services.Id
                where BillDetails.BillId = @billId",
                           new { billId })
                       .AsList();

            list.ForEach
            (
                s => s.BelongToRoom = LazyWorker <Room> .Get(s.RoomId ?? 0)
            );

            return(list);
        }
Exemple #28
0
 private void AddServiceButton_Click(object sender, EventArgs e)
 {
     if (currentBill.Id == 0 || ServiceComboBox.SelectedIndex == 0)
     {
         FormUtilities.NotifyFailure();
         return;
     }
     if (LazyWorker <BillDetail> .Insert(FilledDataToBillDetail()) > 0)
     {
         LoadBillsServices();
         FormUtilities.NotifySuccess();
     }
     else
     {
         FormUtilities.NotifyFailure();
     }
 }
Exemple #29
0
 private void RemoveServiceButton_Click(object sender, EventArgs e)
 {
     if (currentBill.Id == 0)
     {
         FormUtilities.NotifyFailure();
         return;
     }
     if (LazyWorker <BillDetail> .Delete(FilledDataToBillDetail()))
     {
         LoadBillsServices();
         FormUtilities.NotifySuccess();
     }
     else
     {
         FormUtilities.NotifyFailure();
     }
 }
        private void LoadAllEmployees()
        {
            LazyWorker <Employee> .LoadAllToGridView(gridView : EmployeeGridView,
                                                     columnNames : new string[] { "Id", "Username", "Password", "IsAdmin",
                                                                                  "RealLifeIdNumber", "FullName", "DateOfBirth", "Sex",
                                                                                  "Address", "Phonenumber" });

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

            EmployeeGridView.Columns["Username"].Width      = 110;
            EmployeeGridView.Columns["Username"].HeaderText = "Tên đăng nhập";

            EmployeeGridView.Columns["Password"].Width      = 100;
            EmployeeGridView.Columns["Password"].HeaderText = "Mật khẩu";
            EmployeeGridView.Columns["Password"].Visible    = false;

            EmployeeGridView.Columns["IsAdmin"].HeaderText = "Là quản trị viên?";
            EmployeeGridView.Columns["IsAdmin"].AutoSizeMode
                = DataGridViewAutoSizeColumnMode.AllCells;

            EmployeeGridView.Columns["RealLifeIdNumber"].HeaderText = "Số CMND";
            EmployeeGridView.Columns["RealLifeIdNumber"].AutoSizeMode
                = DataGridViewAutoSizeColumnMode.AllCells;

            EmployeeGridView.Columns["FullName"].HeaderText = "Họ tên";
            EmployeeGridView.Columns["FullName"].Width      = 125;

            EmployeeGridView.Columns["DateOfBirth"].HeaderText = "Ngày sinh";
            EmployeeGridView.Columns["DateOfBirth"].AutoSizeMode
                = DataGridViewAutoSizeColumnMode.AllCells;

            EmployeeGridView.Columns["Sex"].HeaderText = "Giới tính";
            EmployeeGridView.Columns["Sex"].AutoSizeMode
                = DataGridViewAutoSizeColumnMode.AllCells;
            EmployeeGridView.Columns["Sex"].Visible = false;

            EmployeeGridView.Columns["Address"].HeaderText = "Địa chỉ";
            EmployeeGridView.Columns["Address"].Width      = 125;

            EmployeeGridView.Columns["Phonenumber"].HeaderText = "Số điện thoại";
            EmployeeGridView.Columns["Phonenumber"].AutoSizeMode
                = DataGridViewAutoSizeColumnMode.AllCells;

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