protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["out_trade_no"] != null && Request.QueryString["returncode"] != null && Request.QueryString["total_fee"] != null && Request.QueryString["sign"] != null) { string out_trade_no = Request.QueryString["out_trade_no"];//订单号. string returncode = Request.QueryString["returncode"]; string total_fee = Request.QueryString["total_fee"]; string sign = Request.QueryString["sign"]; string key = ConfigurationManager.AppSettings["key"].ToString(); string mysign = common.WebComm.CreateMd5(out_trade_no + returncode + total_fee + key).ToLower(); //数字签名 if (mysign == sign) //对数字签名进行比较 { if (returncode == "ok") { BLL.OrdersManager bll = new BookShop.BLL.OrdersManager(); Model.Orders model = bll.GetModel(out_trade_no); if (model != null) { model.State = 1;//如果订单存在,修改该订单的状态,1:表示已付款未发货. bll.Update(model); Response.Redirect("/showinfo.aspx?msg=" + Server.UrlEncode("支付成功,等待发货!") + "&url=OrderDetail.aspx?orderId=" + out_trade_no + "&txt=" + Server.UrlEncode("查看订单信息!")); } } } } }
/// <summary> /// 订单创建 /// </summary> /// <param name="ordersList"></param> /// <param name="orderTypeList"></param> /// <returns></returns> public bool CreateOrders(IList <Sys.Model.Orders> ordersList, IList <Sys.Model.OrderType> orderTypeList) { bool result = false; try { if (ordersList.Count > 0) { Model.Orders ordersModel = ordersList[0]; ordersModel.CreateDate = DateTime.Now; var orderId = dal.Add(ordersModel, 1); foreach (Model.OrderType item in orderTypeList) { item.OrderId = orderId; new Sys.BLL.OrderType().Add(item); } result = true; } } catch (Exception ex) { UtilLog.WriteExceptionLog("CreateOrders Error", ex); } return(result); }
public ActionResult PayOrdersNow(string Remark) { #region 生成订单 string ids = Request["ids"].TrimEnd(','); Business.Sys_Flower Sys_Flower = new Business.Sys_Flower(); Business.Sys_OrdersManaage Sys_OrdersManaage = new Business.Sys_OrdersManaage(); string[] idarry = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string FlowerNum = Request["FlowerNums"]; string[] FlowerNumarry = FlowerNum.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string ConsigneAaddress = Request["DetailedAddress"]; string ConsigneeName = Request["ConsigneeName"]; string ConsigneePhone = Request["ConsigneePhone"]; //唯一的订单 Model.Orders Orders = new Model.Orders(); Orders.UsersId = int.Parse(userid); Orders.CreateTime = DateTime.Now; Orders.OrdersState = 1; Orders.OrderId = Utility.ChangeText.OrderIdCreate(); Orders.GoodsSum = int.Parse(Request["goodnum"]);// 总件数 Orders.ConsigneeName = ConsigneeName; Orders.ConsigneePhone = ConsigneePhone; Orders.ConsigneAaddress = ConsigneAaddress; //详情列表 List <Model.OrdersDetails> OrdersDetailsList = new List <Model.OrdersDetails>(); for (int j = 0; j < idarry.Length; j++) { //每一种花 Model.Flower Flower = Sys_Flower.GetFlower(idarry[j]); Orders.SellingPrice += Flower.FlowerSalesPrice * int.Parse(FlowerNumarry[j]); Orders.CostPrice += Flower.FlowerCostPrice * int.Parse(FlowerNumarry[j]); //每种花对应的数量 for (int i = 0; i < int.Parse(FlowerNumarry[j]); i++) { Model.OrdersDetails OrdersDetails = new Model.OrdersDetails(); OrdersDetails.OrderId = Orders.OrderId; OrdersDetails.FlowerNumber = Flower.FlowerNumber; OrdersDetails.FlowerWatchName = Flower.FlowerWatchName; OrdersDetails.FlowerWatchPhoto = Flower.FlowerWatchPhoto; OrdersDetails.SellingPrice = Flower.FlowerSalesPrice; OrdersDetails.SellingNum = 1; OrdersDetails.CostPrice = Flower.FlowerCostPrice; OrdersDetailsList.Add(OrdersDetails); } } Model.OrdersLog OrdersLog = new Model.OrdersLog(); OrdersLog.OrdersId = Orders.OrderId; OrdersLog.OrdersState = 1; OrdersLog.UserName = Utility.ChangeText.GetUserName(); OrdersLog.Remark = Remark; OrdersLog.Time = DateTime.Now; #endregion Sys_OrdersManaage.TransactionAddOrders(Orders, OrdersDetailsList, OrdersLog); //return Redirect("/WxPay/Index?OrdersId=" + Orders.OrderId + "&PayTotal=" + Orders.SellingPrice); return(Json(new { OrdersId = Orders.OrderId, PayTotal = Orders.SellingPrice }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 非事务订单 /// </summary> /// <returns></returns> public bool InsertOrders(Model.Orders orders, List <Model.OrdersDetails> ordersDetailList, Model.OrdersLog ordersLog) { const string sql = @"insert into Orders (OrderId,SellingPrice,CostPrice,profit,UsersId,ConsigneeName,ConsigneePhone,ConsigneAaddress,OrdersState,GoodsSum) values(@OrderId,@SellingPrice,@CostPrice,@profit,@UsersId,@ConsigneeName,@ConsigneePhone,@ConsigneAaddress,@OrdersState,@GoodsSum)"; Factory.DBHelper.ExecSQL(SQLConString, sql.ToString(), new DynamicParameters(new { orders.OrderId, orders.SellingPrice, orders.CostPrice, orders.profit, orders.UsersId, orders.ConsigneeName, orders.ConsigneePhone, orders.ConsigneAaddress, orders.OrdersState, orders.GoodsSum, })); const string OrdersLog = @"insert into OrdersLog(OrdersId,UserName,OrdersState,Remark) values(@OrdersId,@UserName,@OrdersState,@Remark)"; Factory.DBHelper.ExecSQL(SQLConString, OrdersLog.ToString(), new DynamicParameters(new { ordersLog.OrdersId, ordersLog.UserName, ordersLog.OrdersState, ordersLog.Remark, })); // foreach (Model.OrdersDetails item in ordersDetailList) { const string OrdersDetail = @"insert into OrdersDetails(OrderId,FlowerWatchName,FlowerWatchPhoto,FlowerNumber, SellingPrice,CostPrice,profit,SellingNum) values(@OrderId,@FlowerWatchName,@FlowerWatchPhoto,@FlowerNumber,@SellingPrice, @CostPrice,@profit,@SellingNum)"; Factory.DBHelper.ExecSQL(SQLConString, OrdersDetail.ToString(), new DynamicParameters(new { item.OrderId, item.FlowerWatchName, item.FlowerWatchPhoto, item.FlowerNumber, item.SellingPrice, item.CostPrice, item.profit, item.SellingNum, })); } return(true); }
private async void dgvOrders_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { Model.Orders id = (Model.Orders)dgvOrders.SelectedRows[0].DataBoundItem; var model = await _ordersService.GetById<Model.Orders>(id.Id); frmOrderOption frm = new frmOrderOption(model); frm.ShowDialog(); } catch { MessageBox.Show("Nothing selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString["orderId"])) { BLL.OrdersManager orderBll = new BookShop.BLL.OrdersManager(); orderModel = orderBll.GetModel(Request.QueryString["orderId"]); if (orderModel != null)//判断该订单是否存在 { BLL.OrderBookManager orderBookBll = new BookShop.BLL.OrderBookManager(); List <Model.OrderBook> list = orderBookBll.GetModelList("OrderID='" + Request.QueryString["orderId"] + "'");//根据订单号获取订单的详细信息;注意 给接收到的订单号加上 ' ' (单引号) this.rptDetails.DataSource = list; this.rptDetails.DataBind(); } } }
public ActionResult CreateOrders() { string GoodsId = Request["GoodsId"]; Business.Sys_Flower Sys_Flower = new Business.Sys_Flower(); Model.Flower Flower = Sys_Flower.GetFlowerByFlowerNumber(GoodsId); //判断库存是否足够商品 if (Flower.FlowerStock < Convert.ToInt32(Request["FlowerStock"])) { ViewData["success"] = "抱歉,库存不足"; return(View()); } Model.Orders Orders = new Model.Orders(); Orders.OrderId = Utility.ChangeText.GenerateOutTradeNo(); Orders.OrdersState = 1; Orders.SellingPrice = Flower.FlowerSalesPrice * Convert.ToInt32(Request["FlowerStock"]); Orders.CostPrice = Flower.FlowerCostPrice * Convert.ToInt32(Request["FlowerStock"]); Orders.ConsigneAaddress = Request["ConsigneAaddress"]; Orders.ConsigneeName = Request["ConsigneeName"]; Orders.GoodsSum = Convert.ToInt32(Request["FlowerStock"]); Orders.ConsigneePhone = Request["ConsigneePhone"]; List <Model.OrdersDetails> OrdersDetailsList = new List <Model.OrdersDetails> (); for (int i = 0; i < Convert.ToInt32(Request["FlowerStock"]); i++) { Model.OrdersDetails OrdersDetails = new Model.OrdersDetails(); OrdersDetails.OrderId = Orders.OrderId; OrdersDetails.SellingPrice = Flower.FlowerSalesPrice; OrdersDetails.FlowerNumber = Flower.FlowerNumber; OrdersDetails.CostPrice = Flower.FlowerCostPrice; OrdersDetails.FlowerWatchPhoto = Flower.FlowerWatchPhoto; OrdersDetails.SellingNum = 1; OrdersDetails.FlowerWatchName = Flower.FlowerWatchName; OrdersDetailsList.Add(OrdersDetails); } Model.OrdersLog OrdersLog = new Model.OrdersLog(); OrdersLog.OrdersId = Orders.OrderId; OrdersLog.OrdersState = 1; OrdersLog.UserName = Utility.ChangeText.GetUserName(); Business.Sys_OrdersManaage Sys_OrdersManaage = new Business.Sys_OrdersManaage(); if (!Sys_OrdersManaage.InsertOrders(Orders, OrdersDetailsList, OrdersLog)) { ViewData["success"] = "下单失败,请联系管理员"; return(View()); } return(RedirectToAction("", "")); }
public override String add(HttpContext context) { //判断上月的的定时任务是否处理完毕 if (!new BLL.LogMonthCreateBLL().IsCreate()) { return("上月会员职级未升级完毕,暂时不允许录入订单!"); } Model.Orders orders = new Model.Orders(); String AgentId = context.Request.Params["AgentId"].ToString(); String Price = context.Request.Params["Price"].ToString(); String OrdersId = context.Request.Params["OrdersId"].ToString(); DataTable dt = new BLL.AgentsBLL().GetAgents(" and Id='" + AgentId + "'"); if (dt.Rows.Count == 0) { return("代理人不存在"); } String yearMonth = DateTime.Now.ToString("yyMM"); String id = yearMonth + "0001"; String oldId = new BLL.OrdersBLL().getLastId(); if (!String.IsNullOrWhiteSpace(oldId)) { if (oldId.StartsWith(yearMonth)) { id = (Convert.ToInt32(oldId) + 1).ToString(); } } orders.Id = id; orders.Price = Convert.ToDecimal(Price); orders.AgentName = dt.Rows[0]["AgentsName"].ToString(); orders.State = Convert.ToInt32(MyData.OrdersState.正常); orders.AgentId = AgentId; orders.CreatePerson = userName; orders.CreateTime = DateTime.Now; orders.UpdatePerson = userName; orders.UpdateTime = DateTime.Now; orders.YearMonth = MyData.Utils.getYearMonth(); orders.YearMonthDate = DateTime.Now; if (new BLL.OrdersBLL().Insert(orders, OrdersId)) { return("0"); } return("添加失败!"); }
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString["orderid"])) { BLL.OrdersManager bll = new BookShop.BLL.OrdersManager(); Model.Orders model = bll.GetModel(Request.QueryString["orderid"]); if (model != null) { if (model.State == 1) { Response.Write("以付款,无需重新付款"); } else { PayGet.PayProcess process = new BookShop.Web.PayGet.PayProcess("图书", "网上书城", Request.QueryString["orderid"], model.TotalPrice.ToString()); string url = process.GoPayPage(); Response.Redirect(url);//向支付宝发出请求. } } } }
protected void btnSend_Click(object sender, EventArgs e) { OrdersManager orderManager = new OrdersManager(); string orderId = Request.QueryString["id"]; Model.Orders oneOrder = orderManager.GetModel(orderId); if (oneOrder == null) { return; } else { if (oneOrder.State == 2) { Response.Write("此定单已经发货,不要重复操作!"); return; } oneOrder.State = 2; orderManager.Update(oneOrder); Response.Write("已发货!"); } }
protected void btnBilling_Click(object sender, EventArgs e) { double OriginalPrice = 0; double TotalPrice = 0; List <Model.OrderBook> orderBooksLsit = new List <Model.OrderBook>(); Model.Orders orders = new Model.Orders(); for (int i = 0; i < Repeater1.Items.Count; i++) { CheckBox chksel = Repeater1.Items[i].FindControl("cbBook") as CheckBox; if (chksel.Checked) { Model.OrderBook orderBook = new Model.OrderBook(); DataRow BookDr = BookLsitDs.Tables[0].Rows[i]; TextBox txtBookAmount = Repeater1.Items[i].FindControl("txtBookAmount") as TextBox; int bookmun = Convert.ToInt32(txtBookAmount.Text.Trim()); OriginalPrice += Convert.ToDouble(BookDr["UnitPrice"]) * bookmun; orderBook.Quantity = Convert.ToInt32(txtBookAmount.Text.Trim()); orderBook.UnitPrice = Convert.ToDecimal(BookDr["UnitPrice"]); orderBook.BookID = Convert.ToInt32(BookDr["Id"]); orderBooksLsit.Add(orderBook); } } TotalPrice = OriginalPrice * 0.75; orders.TotalPrice = Convert.ToDecimal(TotalPrice); orders.UserId = user.Id; orders.OrderDate = DateTime.Now; orders.Id = ordersM.Add(orders); foreach (Model.OrderBook order in orderBooksLsit) { order.OrderID = orders.Id; temporaryCart.Delete(order.BookID, user.Id); orderBookM.Add(order); } Session["Order"] = orders; MessageBox.ShowAndRedirect(this, "购买成功!", "Indent.aspx"); }
private async void btnSave_Click(object sender, EventArgs e) { if (_productsAdd.Count == 0) { MessageBox.Show("No added products!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Model.Orders _order = new Model.Orders(); OrdersUpsertRequest orderRequest = new OrdersUpsertRequest { Date = DateTime.Now, OrderNumber = Helper.GenerateString(generatedSize), Status = OrderStatusTypes.Created.ToString(), Cancel = false, UserId = _loggedUser.Id }; try { _order = await _ordersService.Insert <Model.Orders>(orderRequest); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (_order != null) { OutputsUpsertRequest outputsRequest = new OutputsUpsertRequest { Date = DateTime.Now, OrderId = _order.Id, Finished = false, UserId = _loggedUser.Id, ValueWithoutPdv = 0, ValueWithPdv = 0, ReceiveNumber = _order.OrderNumber }; try { _outputs = await _outputsService.Insert <Model.Outputs>(outputsRequest); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } await Helper.CalculateInputProductsPrice(_productsAdd); List <OutputProductsUpsertRequest> list = new List <OutputProductsUpsertRequest>(); foreach (var item in _productsAdd) { OutputProductsUpsertRequest tmp = new OutputProductsUpsertRequest { OutputId = _outputs.Id, ProductId = item.ProductId, Price = item.Price, Quantity = item.Quantity, Discount = item.Quantity / 2 }; if (tmp.Quantity > 100) { tmp.Discount = 50; } if (tmp.Quantity < 20) { tmp.Discount = 0; } try { await _outputProductsService.Insert <Model.OutputProducts>(tmp); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } await CalculateOutputValue(); MessageBox.Show("Success", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } }
public frmProducts(Model.Orders order = null) { _orders = order; InitializeComponent(); }
public frmOrderOption(Model.Orders order = null) { _orders = order; InitializeComponent(); }
public frmOrderStatus(Model.Orders order = null) { _orders = order; InitializeComponent(); }
/// <summary> /// 事务批量执行SQL语句 /// </summary> /// <param name="SQLList">SQL集合</param> /// <param name="SqlParameterList">参数集合</param> /// <returns></returns> public bool TransactionAddOrders(Model.Orders orders, List <Model.OrdersDetails> ordersDetailList, Model.OrdersLog ordersLog) { using (SqlConnection conn = new SqlConnection(SQLConString)) { conn.Open(); SqlTransaction tr = conn.BeginTransaction();//声明事务 SqlCommand comm = new SqlCommand(); comm.Connection = conn; //指定给SqlCommand事务 comm.Transaction = tr; try { #region order //遍历Hashtable数据,每次遍历执行SqlCommand const string sql = @"insert into Orders (OrderId,SellingPrice,CostPrice,profit,UsersId,ConsigneeName,ConsigneePhone,ConsigneAaddress,OrdersState,GoodsSum) values(@OrderId,@SellingPrice,@CostPrice,@profit,@UsersId,@ConsigneeName,@ConsigneePhone,@ConsigneAaddress,@OrdersState,@GoodsSum)"; string cmdText = sql; SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@OrderId", orders.OrderId), new SqlParameter("@SellingPrice", orders.SellingPrice), new SqlParameter("@CostPrice", orders.CostPrice), new SqlParameter("@profit", orders.profit), new SqlParameter("@UsersId", orders.UsersId), new SqlParameter("@ConsigneeName", orders.ConsigneeName), new SqlParameter("@ConsigneePhone", orders.ConsigneePhone), new SqlParameter("@ConsigneAaddress", orders.ConsigneAaddress), new SqlParameter("@OrdersState", orders.OrdersState), new SqlParameter("@GoodsSum", orders.GoodsSum), }; //指定执行语句 comm.CommandText = cmdText; //有参数则进行添加 if (pars != null) { comm.Parameters.AddRange(pars); } //执行 comm.ExecuteNonQuery(); //使用后清空参数,为下次使用 comm.Parameters.Clear(); #endregion #region OrdersLog //遍历Hashtable数据,每次遍历执行SqlCommand const string OrdersLog = @"insert into OrdersLog(OrdersId,UserName,OrdersState,Remark) values(@OrdersId,@UserName,@OrdersState,@Remark)"; SqlParameter[] parsl = new SqlParameter[] { new SqlParameter("@OrdersId", ordersLog.OrdersId), new SqlParameter("@UserName", ordersLog.UserName), new SqlParameter("@OrdersState", ordersLog.OrdersState), new SqlParameter("@Remark", ordersLog.Remark), }; //指定执行语句 comm.CommandText = OrdersLog; //有参数则进行添加 if (parsl != null) { comm.Parameters.AddRange(parsl); } //执行 comm.ExecuteNonQuery(); //使用后清空参数,为下次使用 comm.Parameters.Clear(); #endregion #region detail foreach (Model.OrdersDetails item in ordersDetailList) { const string OrdersDetail = @"insert into OrdersDetails(OrderId,FlowerWatchName,FlowerWatchPhoto,FlowerNumber, SellingPrice,CostPrice,profit,SellingNum) values(@OrderId,@FlowerWatchName,@FlowerWatchPhoto,@FlowerNumber,@SellingPrice, @CostPrice,@profit,@SellingNum)"; SqlParameter[] parsd = new SqlParameter[] { new SqlParameter("@OrderId", item.OrderId), new SqlParameter("@FlowerWatchName", item.FlowerWatchName), new SqlParameter("@FlowerWatchPhoto", item.FlowerWatchPhoto), new SqlParameter("@SellingPrice", item.SellingPrice), new SqlParameter("@FlowerNumber", item.FlowerNumber == null ? "":item.FlowerNumber), new SqlParameter("@CostPrice", item.CostPrice), new SqlParameter("@profit", item.profit), new SqlParameter("@SellingNum", item.SellingNum), }; //指定执行语句 comm.CommandText = OrdersDetail; //有参数则进行添加 if (pars != null) { foreach (SqlParameter par in parsd) { comm.Parameters.Add(par); } } //执行 comm.ExecuteNonQuery(); //使用后清空参数,为下次使用 comm.Parameters.Clear(); } #endregion //不出意外事务提前,返回True tr.Commit(); return(true); } catch (Exception ex) { //出意外事务回滚,返回Fasle tr.Rollback(); return(false); } } }
/// <summary> /// 添加一条数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Add(Model.Orders model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Update(Model.Orders model) { return(dal.Modify(model)); }