private void listbox_Orders_DoubleClick(object sender, EventArgs e) { OrderRent orderRent = listbox_Orders.SelectedItem as OrderRent; OrderRentToFrom(orderRent); ClientToForm(orderRent.Client); ProductToForm(orderRent.Product); listbox_Clients.SelectedValue = orderRent.Client.Id; listbox_Cars.SelectedValue = orderRent.Product.Id; CarExtraArr carExtraArrInOrder = new CarExtraArr(); OrderDetailsRentArr orderDetailsRentArr = new OrderDetailsRentArr(); orderDetailsRentArr.Fill(); orderDetailsRentArr = orderDetailsRentArr.Filter(orderRent); carExtraArrInOrder = orderDetailsRentArr.GetCarExtraArr(); CarExtraArrToForm(carExtraArrInOrder, listbox_InOrder); CarExtraArr carExtraArrNotInOrder = new CarExtraArr(); carExtraArrNotInOrder.Fill(); carExtraArrNotInOrder.Remove(carExtraArrInOrder); CarExtraArrToForm(carExtraArrNotInOrder, listbox_Potential); }
private void btn_Return_Click(object sender, EventArgs e) { OrderRent orderRent = (listbox_Cars.SelectedItem as OrderRent); OrderDetailsRentArr orderDetailsRentArr = new OrderDetailsRentArr(); orderDetailsRentArr.Fill(); CarExtraArr carExtraArr = orderDetailsRentArr.GetCarExtraArrByOrder(orderRent); foreach (CarExtra carExtra in carExtraArr) { carExtra.Count += 1; } orderRent.Product.Doesavailable = ""; if (MessageBox.Show("Are you sure you want to return this car?", "Returnning car", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { if (orderRent.Product.Update()) { carExtraArr.Update(); CarsArrToForm(null); ClearForm(); } } }
public CarExtraArr GetCarExtraRent(PayRent payRent) { OrderRent order = payRent.Order; OrderDetailsRentArr orderDetailsRentArr = new OrderDetailsRentArr(); orderDetailsRentArr.Fill(); orderDetailsRentArr = orderDetailsRentArr.Filter(order); return(orderDetailsRentArr.GetCarExtraArr()); }
private OrderDetailsRentArr FormToOrderDetailsRentArr(OrderRent curOrder) { OrderDetailsRentArr orderDetailsRentArr = new OrderDetailsRentArr(); OrderDetailsRent orderDetailsRent; for (int i = 0; i < listbox_InOrder.Items.Count; i++) { orderDetailsRent = new OrderDetailsRent(); orderDetailsRent.OrderRent = curOrder; orderDetailsRent.CarExtra = listbox_InOrder.Items[i] as CarExtra; orderDetailsRentArr.Add(orderDetailsRent); } return(orderDetailsRentArr); }
public void CarExtraRentToChart(DateTime dt) { RadioButton(true); chart1.Palette = ChartColorPalette.SeaGreen; chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 1; chart1.Titles.Clear(); chart1.Titles.Add("Distribution"); SortedDictionary <string, int> dictionary = new SortedDictionary <string, int>(); OrderDetailsRentArr order = new OrderDetailsRentArr(); order.Fill(); CarExtraArr car = order.GetCarExtraArr(); foreach (CarExtra extra in car) { Count = order.Filter(extra, dt).Count; if (Count > 0) { dictionary.Add(extra.Name, Count); } } Series series = new Series("Car Extra", car.Count); series.ChartType = SeriesChartType.Column; series.Label = "[#PERCENT{P0}]"; series.Points.DataBindXY(dictionary.Keys, dictionary.Values); chart1.Series.Clear(); chart1.Series.Add(series); }
private void btn_Delete_Click(object sender, EventArgs e) { CarExtra carExtra = FormToCarExtra(); OrderDetailsBuyArr orderDetailsBuyArr = new OrderDetailsBuyArr(); orderDetailsBuyArr.Fill(); OrderDetailsRentArr orderDetailsRentArr = new OrderDetailsRentArr(); orderDetailsRentArr.Fill(); if (carExtra.Id == 0) { } else { if (orderDetailsBuyArr.DoesExist(carExtra) || orderDetailsRentArr.DoesExist(carExtra)) { MessageBox.Show("You can not delete this Car Extra, it is connected" + " to 1 or more Orders", "Can not delete Car Extra", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (MessageBox.Show("Are you sure you want to delete this" + " CarExtra? ", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { carExtra.Delete(); ClearForm(); CarExtraArrToForm(null); } } } }
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(); } } } }