private void btAddNewOrder_Click(object sender, EventArgs e) { var endDate = dtpEndDate.Value.Date; var startDate = dtpStartDate.Value.Date; var daysRent = (endDate - startDate).Days; if (startDate.CompareTo(endDate) < 0) { var rentOrder = new SqlRentOrderRepository(Globals.connectionString); rentOrder.CreateRent(new RentOrder() { IdCustomer = _customerId, IdOperator = Globals.currentOperatorId, IdTool = _toolId, RentStatus = 1, RentPrice = daysRent * _cost, DateStart = startDate, DateEnd = endDate }); this.Close(); } else { MessageBox.Show("Please enter correct date", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btShowAllRents_Click(object sender, EventArgs e) { dgvRentOrders.AutoGenerateColumns = false; var showRent = new SqlRentOrderRepository(Globals.connectionString); var resList = showRent.SelectAll(); dgvRentOrders.DataSource = resList; }
private void btCloseRentOrder_Click(object sender, EventArgs e) { var closeRent = new SqlRentOrderRepository(Globals.connectionString); closeRent.CloseRent(Convert.ToInt32(dgvRentOrders.SelectedRows[0].Cells[0].Value)); btShowAllRents_Click(sender, e); }