Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
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);
     }
 }