public IActionResult SaveOrder() { var sessionOrder = Utils.GetCurrentOrder(HttpContext.Session); client.AddOrder(sessionOrder); return(View()); }
private void BT_AddOrder_Click(object sender, EventArgs e) { if (LB_Version.SelectedIndex < 0) { MessageBox.Show("请选择您要预定的车型!"); return; } int VersionID = List_Version.Where(P => P.Version_Name == LB_Version.SelectedItem.ToString()).Single().Version_ID; int Versiontotal = List_Version.Where(P => P.Version_Name == LB_Version.SelectedItem.ToString()).Single().Version_Count; string[] starttime = TM_Start.Value.ToShortDateString().Split('/'); string[] endtime = TM_Back.Value.ToShortDateString().Split('/'); int Car_Count = OrderSummery_Client.SelectRentaledCarCount_TimeAndVersion( ShopID, VersionID, Convert.ToInt32(starttime[0]), Convert.ToInt32(starttime[1]), Convert.ToInt32(starttime[2]), Convert.ToInt32(endtime[0]), Convert.ToInt32(endtime[1]), Convert.ToInt32(endtime[2]) ); int nokosite = Versiontotal - Car_Count; if (nokosite < Convert.ToInt32(TB_Count.Text)) { MessageBox.Show(String.Format("该车型目前只剩下{0}辆,您预定的数量超过库存数量!", nokosite)); return; } else { DialogResult res = MessageBox.Show("您是否确定要将这条订单添加到数据库?", "警告!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); if (res == DialogResult.Cancel) { return; } bool iscatch; int RentalType; int ActionID = List_Action.Where(P => P.Action_Name == CB_Action.SelectedItem.ToString()).Single().Action_ID; if (RB_Self.Checked) { iscatch = false; } else { iscatch = true; } if (RB_SelfGet.Checked) { RentalType = 1; } else { RentalType = 2; } OrderService.Car_Order Temp = new OrderService.Car_Order() { Order_Action = ActionID, Order_Count = Convert.ToInt32(TB_Count.Text), Order_End_Time = new DateTime(Convert.ToInt32(endtime[0]), Convert.ToInt32(endtime[1]), Convert.ToInt32(endtime[2])), Order_Start_Time = new DateTime(Convert.ToInt32(starttime[0]), Convert.ToInt32(starttime[1]), Convert.ToInt32(starttime[2])), Order_IsCatch = iscatch, Order_Message = TB_Message.Text, Order_RentalType = RentalType, Order_Shop = ShopID, Order_User = List_User.Where(P => P.UserName == Label_User.Text).Single().UserID, Order_Version = VersionID, Order_Time = DateTime.Now }; if (Order_Client.AddOrder(Temp)) { MessageBox.Show("提交订单成功!"); List_Version = Version_Client.SelectAllVersions().Where(P => P.Version_Shop == ShopID).ToList(); } else { MessageBox.Show("提交订单失败!请检查拼写,如错误依旧,请联系管理员!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } }