public string GetAllCommodity() { ResultInfo <List <object> > data = new ResultInfo <List <object> >(); int pageSize = int.Parse(Request.Params["pagesize"]); int pageNo = int.Parse(Request.Params["pageno"]); string order = Request.Params["order"]; string type = Request.Params["commodityType"]; string commodity_name = Request.Params["commodity_name"]; //查询条件组织 string where = string.Empty; where += " is_del=0 and "; if (!string.IsNullOrEmpty(type)) { where += " type='" + type + "' and "; } if (!string.IsNullOrEmpty(commodity_name)) { where += " name like '%" + commodity_name + "%' and "; } if (!string.IsNullOrEmpty(where)) { where = where.Substring(0, where.Length - 4); } int startIndex = pageSize * (pageNo - 1) + 1; int endIndex = pageSize * pageNo; var dt = new MultiColorPen.BLL.commodity().GetListByPage(where, order, startIndex, endIndex).Tables[0]; data.IsSucceed = true; data.TotalCount = new MultiColorPen.BLL.commodity().GetRecordCount(where); data.Entity = JsonHelper.DataTableToList(dt); return(JsonConvert.SerializeObject(data)); }
public string GetCommodityList() { ResultInfo <List <object> > data = new ResultInfo <List <object> >(); var dt = new MultiColorPen.BLL.commodity().GetList(" is_del='0' ").Tables[0]; if (dt != null && dt.Rows.Count > 0) { data.IsSucceed = true; data.Message = "Get Data!"; data.TotalCount = dt.Rows.Count; } else { data.IsSucceed = false; data.Message = "没有可展示的数据!"; data.TotalCount = 0; } data.Entity = JsonHelper.DataTableToList(dt); return(JsonConvert.SerializeObject(data)); }
public string DeleteCommodity(int id) { ResultInfo result = new ResultInfo(false); var bll = new MultiColorPen.BLL.commodity(); var umodel = bll.GetModel(id); umodel.is_del = "1"; if (bll.Update(umodel)) { result.IsSucceed = true; result.Message = "操作成功!"; PublicClass.AddLog("Operating", "删除商品信息" + umodel.name + "!"); } else { result.IsSucceed = false; result.Message = "删除失败!"; } return(JsonConvert.SerializeObject(result)); }
public string SaveCommodity(string json) { ResultInfo result = new ResultInfo(false); JObject jo = JObject.Parse(json); LoginInfo userInfo = SessionHelper.ReadSession <LoginInfo>(SessionKeys.LoginInfoKey); var bll = new MultiColorPen.BLL.commodity(); //新增 if (jo["id"].ToString() == "-1") { var model = new MultiColorPen.Model.commodity { name = jo["name"].ToString(), number = "NUM" + DateTime.Now.ToString().Replace("/", "").Replace(" ", "").Replace(":", ""), count = (int)jo["count"], price = (decimal)jo["price"], type = jo["type"].ToString(), unit = jo["unit"].ToString(), is_del = "0", special_supply = jo["special_supply"].ToString(), mark = jo["mark"].ToString() }; if (bll.Add(model)) { result.IsSucceed = true; result.Message = "操作成功!"; PublicClass.AddLog("Operating", "新增商品" + model.name + "!"); } else { result.IsSucceed = false; result.Message = "新增失败!"; } } //修改 else { int id = int.Parse(jo["id"].ToString()); var umodel = bll.GetModel(id); umodel.name = jo["name"].ToString(); umodel.count = (int)jo["count"]; umodel.price = (decimal)jo["price"]; umodel.type = jo["type"].ToString(); umodel.unit = jo["unit"].ToString(); umodel.special_supply = jo["special_supply"].ToString(); umodel.mark = jo["mark"].ToString(); List <string> btncode = new List <string>(); if (bll.Update(umodel)) { result.IsSucceed = true; result.Message = "操作成功!"; PublicClass.AddLog("Operating", "编辑商品信息" + umodel.name + "!"); } else { result.IsSucceed = false; result.Message = "修改失败!"; } } return(JsonConvert.SerializeObject(result)); }
public string SingleCommodity(int id) { var dt = new MultiColorPen.BLL.commodity().GetModel(id); return(JsonConvert.SerializeObject(dt)); }
public string SaveOrder(string json, string orderInfo) { //json = json.Replace("[","").Replace("]",""); orderInfo = orderInfo.Replace("[", "").Replace("]", ""); var bllOrder = new MultiColorPen.BLL.order_info(); var bllDetail = new MultiColorPen.BLL.order_detail(); var bllCommo = new MultiColorPen.BLL.commodity(); var bllCustomer = new MultiColorPen.BLL.customer(); bool isSuccess = true; string orderNumber = "";//订单编号 JArray jArray = JArray.Parse(json); var oldOrderInfo = new MultiColorPen.Model.order_info(); ResultInfo result = new ResultInfo(false); JObject jo = JObject.Parse(orderInfo); //解析order信息 if (jo["orderId"].ToString() == "-1") //新增订单 { orderNumber = "ORDER" + DateTime.Now.ToString("yyyyMMddHHmmss"); } else { oldOrderInfo = bllOrder.GetModel((int)jo["orderId"]); //获取旧的订单信息 orderNumber = oldOrderInfo.number; //编辑时使用旧的订单编号 oldOrderInfo.is_del = "1"; if (!bllOrder.Update(oldOrderInfo)) //删除旧的订单信息 { isSuccess = false; } if (!bllDetail.DeleteByWhere(" order_number='" + orderNumber + "'")) //删除详细商品的对应数据 { isSuccess = false; } } foreach (var jj in jArray) { JObject jdata = (JObject)jj; var commodityModel = bllCommo.GetModel((int)jdata["name"]); var orderDetailModel = new MultiColorPen.Model.order_detail(); orderDetailModel.commodity_count = (int)jdata["count"]; orderDetailModel.commodity_id = (int)jdata["name"]; orderDetailModel.commodity_price = commodityModel.price; orderDetailModel.commodity_unit = commodityModel.unit; orderDetailModel.order_number = orderNumber; orderDetailModel.commodity_name = commodityModel.name; orderDetailModel.mark = jdata["mark"].ToString(); orderDetailModel.is_del = "0"; if (!bllDetail.Add(orderDetailModel)) //插入商品详情 { isSuccess = false; } } var customerModel = bllCustomer.GetModel((int)jo["customerId"]); var orderModel = new MultiColorPen.Model.order_info(); orderModel.create_time = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); orderModel.customer_id = (int)jo["customerId"]; orderModel.customer_address = customerModel.address; orderModel.customer_name = customerModel.name; orderModel.customer_person = customerModel.person; orderModel.customer_tel = customerModel.tel; orderModel.delivery_time = jo["deliverTime"].ToString(); orderModel.is_del = "0"; orderModel.status = "已下单"; orderModel.number = orderNumber; orderModel.mark = jo["orderMark"].ToString(); if (!bllOrder.Add(orderModel)) //插入订单信息 { isSuccess = false; } if (isSuccess) { result.IsSucceed = true; result.Message = "操作成功!"; } else { result.IsSucceed = false; result.Message = "修改失败!"; } return(JsonConvert.SerializeObject(result)); }