public DataTable GetByOrdersId(Model.OrdersDetail ordersDetail) { String sql = "select * from OrdersDetail where 1=1 "; if (!String.IsNullOrWhiteSpace(ordersDetail.OrdersId)) { sql += " and OrdersId='" + ordersDetail.OrdersId + "'"; } return(DataBase.Base_dt(sql)); }
public String getDetailByOrdersId(HttpContext context) { Model.OrdersDetail ordersDetail = new Model.OrdersDetail(); String orderId = context.Request.Params["orderId"].ToString(); if (!String.IsNullOrWhiteSpace(orderId)) { ordersDetail.OrdersId = orderId; } else { ordersDetail.OrdersId = ""; } DataTable dt = new BLL.OrdersDetailBLL().GetByOrdersId(ordersDetail); return(MyData.Utils.EasyuiDataGridJson(dt)); }
public override String add(HttpContext context) { BLL.OrdersDetailBLL ordersDetailBll = new BLL.OrdersDetailBLL(); Model.OrdersDetail ordersDetail = new Model.OrdersDetail(); var productId = context.Request.Params["ProductId"].ToString(); var orderId = context.Request.Params["OrdersId"].ToString(); DataTable dt = new BLL.ProductsBLL().getProductsById(productId); if (dt.Rows.Count == 0) { return("产品不存在!"); } DataRow dr = dt.Rows[0]; ordersDetail.Id = System.Guid.NewGuid().ToString(); ordersDetail.OrdersId = orderId; ordersDetail.ProductId = productId; ordersDetail.Num = Convert.ToInt32(context.Request.Params["Num"].ToString()); ordersDetail.ProductName = dr["ProductName"].ToString(); ordersDetail.Price = Convert.ToDecimal(dr["UnitPrice"].ToString()) * Convert.ToInt32(context.Request.Params["Num"].ToString()); ordersDetail.UnitPrice = Convert.ToDecimal(dr["UnitPrice"].ToString()); ordersDetail.CreatePerson = userName; ordersDetail.UpdatePerson = userName; ordersDetail.CreateTime = DateTime.Now; ordersDetail.UpdateTime = DateTime.Now; ordersDetail.State = -1; String ids = ""; int nums = 0; decimal allprice = 0; if (new BLL.OrdersDetailBLL().Insert(ordersDetail)) { DataTable dd = new BLL.OrdersDetailBLL().GetByOrdersId(ordersDetail); foreach (DataRow dr1 in dd.Rows) { ids += dr1["ProductId"].ToString() + ","; nums += Convert.ToInt32(dr1["Num"].ToString()); allprice += Convert.ToDecimal(dr1["Price"].ToString()); } return(ids + "$共" + nums + "件$" + allprice); } return("保存失败"); }
public override String del(HttpContext context) { var id = context.Request.Params["id"].ToString(); var orderId = context.Request.Params["OrdersId"].ToString(); String ids = ""; int nums = 0; decimal allprice = 0; if (new BLL.OrdersDetailBLL().Delete(id)) { Model.OrdersDetail ordersDetail = new Model.OrdersDetail(); ordersDetail.OrdersId = orderId; DataTable dd = new BLL.OrdersDetailBLL().GetByOrdersId(ordersDetail); foreach (DataRow dr1 in dd.Rows) { ids += dr1["ProductId"].ToString() + ","; nums += Convert.ToInt32(dr1["Num"].ToString()); allprice += Convert.ToDecimal(dr1["Price"].ToString()); } return(ids + "$共" + nums + "件$" + allprice); } return("删除失败"); }
public bool Insert(Model.OrdersDetail ordersdetail) { if (!String.IsNullOrWhiteSpace(ordersdetail.CreatePerson)) { String sql = @"INSERT INTO [dbo].[OrdersDetail] ([Id] ,[OrdersId] ,[ProductId] ,[ProductName] ,[UnitPrice] ,[Num] ,[Price] ,[CreateTime] ,[CreatePerson] ,[UpdateTime] ,[UpdatePerson],[State]) VALUES ('{0}','{1}','{2}','{3}',{4},{5},{6},'{7}','{8}','{9}','{10}',{11} );"; sql = String.Format(sql, ordersdetail.Id, ordersdetail.OrdersId, ordersdetail.ProductId, ordersdetail.ProductName, ordersdetail.UnitPrice, ordersdetail.Num, ordersdetail.Price, ordersdetail.CreateTime, ordersdetail.CreatePerson, ordersdetail.UpdateTime, ordersdetail.UpdatePerson, ordersdetail.State); return(DataBase.Base_cmd(sql)); } return(false); }
public bool Insert(Model.OrdersDetail ordersdetail) { return(new DAL.OrdersDetailDal().Insert(ordersdetail)); }
public DataTable GetByOrdersId(Model.OrdersDetail ordersDetail) { DAL.OrdersDetailDal ordersDetailDal = new DAL.OrdersDetailDal(); return(ordersDetailDal.GetByOrdersId(ordersDetail)); }