private void btn_Save_Click(object sender, EventArgs e) { if (CheckForm()) { OrderBuy orderBuy = FormToOrderBuy(); OrderDetailsBuyArr orderDetailsBuyArr_New; OrderDetailsBuyArr orderDetailsBuyArr_Old = new OrderDetailsBuyArr(); OrderBuyArr orderBuyArr_New = new OrderBuyArr(); orderBuyArr_New.Fill(); if (orderBuy.Id == 0) { if (!orderBuyArr_New.DoesExist(orderBuy.Product)) { if (orderBuy.Insert() && orderBuy.Product.Update()) { OrderBuyArr orderBuyArr = new OrderBuyArr(); orderBuyArr.Fill(); orderBuy = orderBuyArr.GetOrderBuyWithMaxId(); orderDetailsBuyArr_New = FormToOrderDetailsBuyArr(orderBuy); orderDetailsBuyArr_New.Insert(); CarExtraArr carExtraArrInOrder = orderDetailsBuyArr_New.GetCarExtraArr(); carExtraArrInOrder.Update(); foreach (TabPage tp in this.tbc_Order.Controls) { ClearForm(tp); } LoadNew(); Form_Pay newform = new Form_Pay(orderBuy); newform.ShowDialog(); } } else { MessageBox.Show("This car already sold", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { if (orderBuy.Update() && orderBuy.Product.Update()) { orderDetailsBuyArr_New = FormToOrderDetailsBuyArr(orderBuy); orderDetailsBuyArr_Old.Fill(); orderDetailsBuyArr_Old = orderDetailsBuyArr_Old.Filter(orderBuy); orderDetailsBuyArr_Old.Delete(); orderDetailsBuyArr_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(); } } } }
private void btn_Pay_Click(object sender, EventArgs e) { Form_Pay newform = new Form_Pay(listbox_Orders.SelectedItem as OrderBuy); newform.ShowDialog(); }
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(); } } } }