private void ProductArrToForm(Product curProduct) { ProductArr productArr = new ProductArr(); // productArr.FillRentAvailableNew(); //productArr.FillRent(); productArr.FillRentAvailable(dtp_From.Value.Date, dtp_To.Value.Date); listbox_Cars.DataSource = productArr; if (productArr != null) { listbox_Cars.ValueMember = "ID"; listbox_Cars.DisplayMember = "FullModel"; } if (curProduct != null) { listbox_Cars.SelectedValue = curProduct.Id; } }
private void btn_Save_Click(object sender, EventArgs e) { if (CheckForm()) { OrderRent orderRent = FormToOrderRent(); OrderDetailsRentArr orderDetailsRentArr_New; OrderDetailsRentArr orderDetailsRentArr_Old = new OrderDetailsRentArr(); ProductArr productArr = new ProductArr(); productArr.FillRentAvailable(dtp_From.Value.Date, dtp_To.Value.Date); if (orderRent.Id == 0) { if (productArr.IsContains(orderRent.Product)) { orderRent.Product.Doesavailable = "InRent"; if (orderRent.Insert() && orderRent.Product.Update()) { OrderRentArr orderRentArr = new OrderRentArr(); orderRentArr.Fill(); orderRent = orderRentArr.GetOrderRentWithMaxId(); orderDetailsRentArr_New = FormToOrderDetailsRentArr(orderRent); orderDetailsRentArr_New.Insert(); CarExtraArr carExtraArrInOrder = orderDetailsRentArr_New.GetCarExtraArr(); carExtraArrInOrder.Update(); foreach (TabPage tp in this.tbc_Order.Controls) { ClearForm(tp); } LoadNew(); Form_Pay newform = new Form_Pay(orderRent); Hide(); newform.ShowDialog(); Close(); } else { } } else { MessageBox.Show("This car already in use", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { if (orderRent.Update()) { orderDetailsRentArr_New = FormToOrderDetailsRentArr(orderRent); orderDetailsRentArr_Old.Fill(); orderDetailsRentArr_Old = orderDetailsRentArr_Old.Filter(orderRent); orderDetailsRentArr_Old.Delete(); orderDetailsRentArr_New.Insert(); (listbox_InOrder.DataSource as CarExtraArr).Update(); (listbox_Potential.DataSource as CarExtraArr).Update(); MessageBox.Show("Your Cerdit Card will be charged accordingly", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); foreach (TabPage tp in this.tbc_Order.Controls) { ClearForm(tp); } LoadNew(); } } } }