Ejemplo n.º 1
0
 protected void lbnSubmitOrder_Click(object sender, EventArgs e)
 {
     using (var db = new ZLzucheEntities())
     {
         var orders = new Orders
             {
                 CustomerID = CustomerHelper.CustomerId,
                 OrderType = "短租",
                 GetCarTime = Convert.ToDateTime(txtTakeTime.Text),
                 ReturnCarTime = Convert.ToDateTime(txtReturnTime.Text),
                 HireDays = Convert.ToString((Convert.ToDateTime(txtReturnTime.Text) - Convert.ToDateTime(txtTakeTime.Text)).Days),
                 CreateTime = DateTime.Now
             };
         var carId = string.IsNullOrEmpty(hfCarId.Value) ? 0 : Convert.ToInt32(hfCarId.Value);
         if (carId > 0)
         {
             var car = db.Car.SingleOrDefault(model => model.ID == carId);
             var orderDetails = new OrderDetails
                 {
                     Orders = orders,
                     CarId = car.ID,
                     Price = car.Price,
                     CarNum = 1,
                     Status = 0,
                     CreateBy = CustomerHelper.CustomerId,
                     CreateTime = DateTime.Now
                 };
             orders.OrderDetails.Add(orderDetails);
         }
         db.Orders.AddObject(orders);
         db.SaveChanges();
         ScriptHelper.Alert(this,"短租订单提交成功");
         var gotoUrl = this.ResolveUrl("ShortRent.aspx");
         ScriptHelper.Goto(this,gotoUrl);
     }
 }
 /// <summary>
 /// 创建新的 Orders 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="customerID">CustomerID 属性的初始值。</param>
 public static Orders CreateOrders(global::System.Int32 id, global::System.Int32 customerID)
 {
     Orders orders = new Orders();
     orders.ID = id;
     orders.CustomerID = customerID;
     return orders;
 }
 /// <summary>
 /// 用于向 Orders EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToOrders(Orders orders)
 {
     base.AddObject("Orders", orders);
 }
Ejemplo n.º 4
0
 protected void lbnSubmit_Click(object sender, EventArgs e)
 {
     using (var db = new ZLzucheEntities())
     {
         var orders = new Orders
         {
             CustomerID = CustomerHelper.CustomerId,
             OrderType = "长租",
             GetCarTime = Convert.ToDateTime(GetCarTime.Text),
             RentMonth =Convert.ToInt32(ddlRentCycle.Text),
             LinkMan = txtLinkMan.Text,
             Phone =  txtPhone.Text,
             CompanyName = txtCompanyName.Text,
             Email =  txtEmail.Text,
             CreateTime = DateTime.Now
         };
         var carId = string.IsNullOrEmpty(CarName.Text) ? 0 : Convert.ToInt32(CarName.Text);
         if (carId > 0)
         {
             var car = db.Car.SingleOrDefault(model => model.ID == carId);
             var orderDetails = new OrderDetails
             {
                 Orders = orders,
                 CarId = car.ID,
                 Price = car.MonthPrice,
                 CarNum = Convert.ToInt32(txtRentNum.Text),
                 Status = 0,
                 CreateBy = CustomerHelper.CustomerId,
                 CreateTime = DateTime.Now
             };
             orders.OrderDetails.Add(orderDetails);
         }
         db.Orders.AddObject(orders);
         db.SaveChanges();
         ScriptHelper.Alert(this, "长租订单提交成功");
         var gotoUrl = this.ResolveUrl("~/LongRent.aspx");
         ScriptHelper.Goto(this, gotoUrl);
     }
 }