private void btnSave_Click(object sender, EventArgs e) { DishInfo model = new DishInfo() { DTitle = txtTitleSave.Text, DTypeId = (int)ddlTypeAdd.SelectedValue, DPrice = Convert.ToDecimal(txtPrice.Text), DChar = txtChar.Text }; if (btnSave.Text == "添加") { if (!bll.Add(model)) { MessageBox.Show("添加失败"); } } else { model.DId = Convert.ToInt32((txtId.Text)); if (!bll.Update(model)) { MessageBox.Show("修改失败"); } } Reset(); LoadList(); }
/// <summary> /// 数据库伪删除 /// </summary> /// <param name="di">要删除的对象</param> /// <returns>影响行数</returns> public int Drop(DishInfo di) { string sql = "Update DishInfo set DIsDelete=1 where did=@id"; //脚本 SQLiteParameter p = new SQLiteParameter("@id", di.DId); //参数 return(SQLiteHelper.ExecuteNonQuery(sql, p)); //执行 }
public ActionResult Edit(int id) { var lstSup = _supRepo.GetAll().Select(x => new SelectListItem { Value = x.id.ToString(), Text = x.SupplierName.ToString(), }).ToList(); ViewBag.lstSup = lstSup; Dish dish = _dishRepo.GetById(id); Supplier sup = new Supplier(); sup = _supRepo.GetById(dish.SupplierId); DishInfo dishInfo = new DishInfo() { id = dish.id, DishCode = dish.DishCode, DishName = dish.DishName, SupplierId = dish.SupplierId, SupplierCode = sup.SupplierCode, SupplierName = sup.SupplierName, Cost = dish.Cost, Description = dish.Description, Image = dish.Image, JugmentPoint = dish.JugmentPoint, JugmentQty = dish.JugmentQty, RegisterQty = dish.RegisterQty, }; return(View("Edit", dishInfo)); }
/// <summary> /// 获取门店的单品信息 /// </summary> /// <param name="shopId"></param> /// <returns></returns> IList <DishInfo> IDishCache.GetDishInfoByShop(int shopId) { IList <DishInfo> result = null; string key = string.Format("DB_DI_*_*_*_{0}", shopId); IList <string> keys = Session.Current.ScanAllKeys(key); if (keys != null && keys.Count > 0) { result = new List <DishInfo>(); for (int i = 0; i < keys.Count; i++) { DishInfo cache = Session.Current.Get <DishInfo>(keys[i]); result.Add(cache); } } else { //从数据库拿取 result = DBConnectionManager.Instance.Reader.Select <DishInfo>(new DishSelectSpefication(shopId.ToString(), 4).Satifasy()); if (result != null && result.Count > 0) { foreach (DishInfo item in result) { //同步到缓存 Session.Current.Set(item.GetKeyName(), item); Session.Current.Expire(item.GetKeyName(), ExpireTime); } } } return(result); }
public int Add(DishInfo model) { try { Dish dish = new Dish(); dish.DishCode = model.DishCode; dish.DishName = model.DishName; dish.SupplierId = model.SupplierId; dish.Cost = model.Cost; dish.Description = model.Description; dish.JugmentPoint = 0; dish.JugmentQty = 0; dish.RegisterQty = 0; dish.Image = model.Image; dish.CreatedDate = DateTime.Now; dish.ModifyDate = DateTime.Now; dish.IsDeleted = 0; db.Dishes.Add(dish); db.SaveChanges(); return(1); } catch (Exception) { return(0); } }
/// <summary> /// 根据编号精确获取单品食物 /// </summary> /// <param name="dishId">单品食物编号</param> /// <returns></returns> public Result <Dish> SearchDishInfoById(int dishId) { Result <Dish> result = new Result <Dish>() { Data = null, Status = true }; try { IDishCache service = ServiceObjectContainer.Get <IDishCache>(); DishInfo dishinfo = service.GetDishInfoById(dishId); if (dishinfo != null) { result.Data = dishinfo.Copy <Dish>(); result.Status = true; } else { result.Status = false; } } catch (Exception ex) { result.Status = false; result.Message = "查询单品食物出错:" + ex.Message; result.StatusCode = "SD001"; LoggerUtils.LogIn(LoggerUtils.ColectExceptionMessage(ex, "At service:SearchDishInfoById() .DishService"), LogType.ErrorLog); } return(result); }
//添加\修改操作 private void buttonadd_Click(object sender, EventArgs e) { DishInfo di = new DishInfo(); di.DTitle = textXmt.Text; di.DTypeId = Convert.ToInt32(comboBox1.SelectedValue); di.DPrice = Convert.ToDecimal(textjg.Text); di.DChar = textpy.Text; if (buttonadd.Text.Equals("添加")) { //添加 if (diBll.Add(di)) { } else { MessageBox.Show("添加失败,请稍后重试!!!"); } } else { //修改 di.DId = Convert.ToInt32(textBh.Text); if (diBll.Edit(di)) { buttoncancel_Click(null, null); LoadList(); } else { MessageBox.Show("修改失败,请稍后重试!!!"); } } }
/// <summary> /// 更新单品信息中门店名称 /// </summary> /// <param name="shopid">门店编号</param> /// <param name="name">更新的门店名称</param> void IDishCache.UpdateDishInfoByChangeShopName(int shopid, string name) { if (shopid == 0 || string.IsNullOrEmpty(name)) { throw new ArgumentNullException("shopid or name can not be null"); } string key = string.Format("DB_DI_*_*_*_{0}", shopid); IList <string> keys = Session.Current.ScanAllKeys(key); if (keys != null && keys.Count > 0) { for (int i = 0; i < keys.Count; i++) { DishInfo dish = Session.Current.Get <DishInfo>(keys[i]); if (dish != null) { dish.ShopName = name; //移除之前的 Session.Current.Remove(keys[i]); Session.Current.Set(dish.GetKeyName(), dish); Session.Current.Expire(dish.GetKeyName(), ExpireTime); } } } }
public string UploadDish() { var meituan = ResturantFactory.CreateResturant(platform); var dish = new DishInfo() { BoxNumber = 1, BoxPrice = 0.1, CategoryName = "冷菜", DishName = "测试菜品1", ErpDishId = "100", Picture = "B98DC1B75A27D699176CB5A6CFFC26D0", Price = 10, Sequence = 1, Unit = "份" }; //dish.SubDishes.Add(new SubDishInfo() //{ // ErpSubDishId = "Sub100", // Price = 10, // Spec = "小份", // Stock = 1 //}); meituan.UploadDish(1, Startup.StoreInfos[1], new List <DishInfo>(new DishInfo[] { dish })); return("ok"); }
private void LoadDishInfo() { DishInfoBll diBll = new DishInfoBll(); DishInfo di = new DishInfo(); dgvAllDish.AutoGenerateColumns = false; dgvAllDish.DataSource = diBll.GetList(di); }
private void txtTitle_TextChanged(object sender, EventArgs e) { DishInfo di = new DishInfo(); di.DTypeId = Convert.ToInt32(ddlType.SelectedValue); di.DChar = txtTitle.Text; dgvAllDish.DataSource = new DishInfoBll().GetList(di); }
private void btnSave_Click(object sender, EventArgs e) { #region 判断是否有输入数据 if (string.IsNullOrWhiteSpace(txtTitleSave.Text)) { MessageBox.Show("请输入菜品名称"); txtTitleSave.Focus(); return; } if (string.IsNullOrWhiteSpace(txtPrice.Text)) { MessageBox.Show("请输入价格"); txtPrice.Focus(); return; } #endregion //获取用户输入数据,构建对象 DishInfo di = new DishInfo() { DTitle = txtTitleSave.Text, DPrice = decimal.Parse(txtPrice.Text), DChar = txtChar.Text, DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue) }; if (txtId.Text.Equals("添加时无编号")) { //添加 if (diBll.Add(di)) { LoadList(); } else { MessageBox.Show("添加失败,请稍候重试"); } } else { //修改 di.DId = int.Parse(txtId.Text); if (diBll.Edit(di)) { LoadList(); } else { MessageBox.Show("修改失败,请稍候重试"); } } //恢复控件 txtId.Text = "添加时无编号"; txtTitleSave.Text = ""; txtPrice.Text = ""; txtChar.Text = ""; ddlTypeAdd.SelectedIndex = 0; btnSave.Text = "添加"; }
public List <DishInfo> GetList(DishInfo di) { //构造sql语句 //链接查询,需要查到MTypeId的会员名称 string sql = "select di.*,dti.dTitle as typetitle from DishInfo di" + " inner join dishtypeinfo dti" + " on di.dtypeid=dti.did" + " where di.dIsDelete=0"; //拼接查询,得到结果 List <SQLiteParameter> listP = new List <SQLiteParameter>(); if (!string.IsNullOrEmpty(di.DTitle)) { //模糊查询 sql += " and di.dtitle like @title"; listP.Add(new SQLiteParameter("@title", "%" + di.DTitle + "%")); } if (di.DTypeId > 0) { sql += " and di.dtypeid like @typeid"; listP.Add(new SQLiteParameter("@typeid", "%" + di.DTypeId + "%")); } //在点餐的时候根据拼音首字母查询 if (!string.IsNullOrEmpty(di.DChar)) { //模糊查询 sql += " and di.dchar like @char"; listP.Add(new SQLiteParameter("@char", "%" + di.DChar + "%")); } sql += " order by di.did desc"; //执行查询,获取数据 DataTable table = SqliteHelper.GetList(sql, listP.ToArray()); //构造集合对象 //定义一个集合用于转存数据 List <DishInfo> list = new List <DishInfo>(); //逐行遍历数据,将表中的数据存到集合中 foreach (DataRow row in table.Rows) { //1.list.Add() //2.new Managerinfo() //3.对象的初始化 list.Add(new DishInfo() { DId = Convert.ToInt32(row["did"]), DTypeId = Convert.ToInt32(row["dtypeid"]), DTitle = row["dtitle"].ToString(), DChar = row["dchar"].ToString(), DPrice = Convert.ToDecimal(row["dprice"]), TypeTitle = row["typetitle"].ToString(), }); } //返回数据 return(list); }
private void btnSave_Click(object sender, EventArgs e) { if ("-请选择-".Equals(ddlTypeAdd.SelectedValue) || "全部".Equals(ddlTypeAdd.SelectedValue)) { MessageBox.Show("请选择菜品分类"); return; } //收集用户输入信息 DishInfo di = new DishInfo() { DTitle = txtTitleSave.Text.Trim(), DChar = txtChar.Text.Trim(), DPrice = Convert.ToDecimal(txtPrice.Text), DTypeTitle = ddlTypeAdd.SelectedValue.ToString() }; if (txtId.Text == "添加时无编号") { #region 添加 if (diBll.Add(di)) { LoadList(); } else { MessageBox.Show("逗b,怎么加的"); } #endregion } else { #region 修改 di.Id = int.Parse(txtId.Text); if (diBll.Update(di)) { LoadList(); } else { MessageBox.Show("你是猴子请来的救兵吗?"); } #endregion } #region 恢复控件 txtId.Text = "添加时无编号"; txtTitleSave.Text = ""; txtPrice.Text = ""; txtChar.Text = ""; ddlTypeAdd.SelectedIndex = 0; #endregion }
public int Delete(DishInfo di) { string sql = "DELETE FROM DishInfo WHERE DId =@id"; SQLiteParameter[] ps = { new SQLiteParameter("@id", di.DId) }; return(SqliteHelper.ExecuteNonQuery(sql, ps)); }
public DishInfo GetDish(int erpStoreId, String token, string erpDishId) { var postDict = new SortedDictionary <string, string>(); postDict["appAuthToken"] = token; postDict["charset"] = "utf-8"; postDict["timestamp"] = (Helper.ConvertDateTimeInt(DateTime.Now)).ToString(); postDict["ePoiId"] = erpStoreId.ToString(); postDict["eDishCodes"] = erpDishId; postDict["sign"] = MeituanHelper.Sign(postDict, this.Config.SignKey); var result = Helper.PostQueryString("http://api.open.cater.meituan.com/waimai/dish/queryListByEdishCodes", postDict, 8000); var jsonObj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result); Newtonsoft.Json.Linq.JToken errobj; if (jsonObj.TryGetValue("error", StringComparison.CurrentCultureIgnoreCase, out errobj)) { throw new Exception(errobj.Value <string>("message")); } var dishJson = ((Newtonsoft.Json.Linq.JArray)jsonObj["data"]["list"])[0]; var dish = new DishInfo(); dish.BoxNumber = dishJson.Value <int>("boxNum"); dish.BoxPrice = dishJson.Value <double>("boxPrice"); dish.CategoryName = dishJson.Value <string>("categoryName"); dish.Description = dishJson.Value <string>("description"); dish.DishName = dishJson.Value <string>("dishName"); dish.ErpDishId = dishJson.Value <string>("eDishCode"); dish.Price = dishJson.Value <double>("price"); dish.Picture = dishJson.Value <string>("picture"); dish.Sequence = dishJson.Value <int>("Sequence"); dish.Unit = dishJson.Value <string>("unit"); var waiMaiDishSkuBases = (Newtonsoft.Json.Linq.JArray)dishJson["skus"]; for (int j = 0; j < waiMaiDishSkuBases.Count; j++) { var skuJson = waiMaiDishSkuBases[j]; var subdish = new DishSkuInfo(); dish.Skus.Add(subdish); subdish.ErpSkuId = skuJson.Value <string>("skuId"); try { subdish.Stock = Convert.ToUInt32(skuJson.Value <string>("stock")); } catch { } subdish.Price = skuJson.Value <double>("price"); subdish.Spec = skuJson.Value <string>("spec"); } return(dish); }
private void LoadDishInfo() { DishInfo di = new DishInfo(); di.DChar = textBox1.Text; di.DTypeId = Convert.ToInt32(comboBox1.SelectedValue); DishInfoBll diBll = new DishInfoBll(); dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = diBll.GetList(di); }
private void LoadDishInfo() { //加载菜品数据容器 DishInfoBll diBll = new DishInfoBll(); DishInfo di = new DishInfo(); //根据Dal的情况分析,这里需要构造一个空的对象进行查询,不能直接用null查询 di.DTypeId = Convert.ToInt32(cbxDishType.SelectedValue); di.DChar = txtPy.Text; gvDishInfo.AutoGenerateColumns = false; gvDishInfo.DataSource = diBll.GetList(di); }
private void LoadList() { DishInfo di = new DishInfo(); if (!string.IsNullOrEmpty(textXms.Text)) { di.DTitle = textXms.Text; } di.DTypeId = Convert.ToInt32(comboBox2.SelectedValue); dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = diBll.GetList(di); }
public int Insert(DishInfo di) { string sql = "insert into DishInfo (DTitle,DTypeId,DPrice,DChar,DIsDelete) values (@DTitle,@DTypeId,@DPrice,@DChar,0)"; SQLiteParameter[] sp = { new SQLiteParameter("DTitle", di.DTitle), new SQLiteParameter("DTypeId", di.DTypeId), new SQLiteParameter("DPrice", di.DPrice), new SQLiteParameter("DChar", di.DChar) }; return(SQLiteHelper.ExecuteNonQuery(sql, sp)); }
/// <summary> /// 修改 /// </summary> /// <param name="dish"></param> /// <returns></returns> public int Update(DishInfo dish) { string sql = "update dishinfo set dtitle=@title,dtypeid=@typeid,dprice=@price where did=@id"; SQLiteParameter [] sp = new SQLiteParameter[] { new SQLiteParameter("@title", dish.DTitle), new SQLiteParameter("@typeid", dish.DTypeId), new SQLiteParameter("@price", dish.DPrice), new SQLiteParameter("@id", dish.DId), }; return(SqliteHelper.ExcuteNoQuery(sql, sp)); }
public int Insert(DishInfo dishInfo) { string sql = "insert into DishInfo(DTitle,DTypeId,DPrice,DChar,DIsdelete) values(@title,@typeId,@price,@char,0)"; SQLiteParameter[] ps = { new SQLiteParameter("@title", dishInfo.DTitle), new SQLiteParameter("@typeid", dishInfo.DTypeId), new SQLiteParameter("@price", dishInfo.DPrice), new SQLiteParameter("@char", dishInfo.DChar) }; return(SqliteHelper.ExecuteNonQuery(sql, ps)); }
private void LoadDishInfoList() { DishInfo di = new DishInfo(); if (!string.IsNullOrEmpty(txtTitleSearch.Text)) { di.DTitle = txtTitleSearch.Text; } di.DTypeId = Convert.ToInt32(cbxTypeSearch.SelectedValue); gvDishInfo.AutoGenerateColumns = false; gvDishInfo.DataSource = diBll.GetList(di); }
//添加 public int Insert(DishInfo di) { string sql = "insert into DishInfo (dtitle, dtypeid, dprice, dchar, dIsDelete) values (@title, @tid, @price, @dchar, 0)"; SQLiteParameter[] ps = { new SQLiteParameter("@title", di.DTitle), new SQLiteParameter("@tid", di.DTypeId), new SQLiteParameter("@price", di.DPrice), new SQLiteParameter("@dchar", di.DChar) }; return(SqliteHelper.ExecuteNonQuery(sql, ps)); }
public int Add(DishInfo model) { string sql = "Insert into DishInfo(Dtitle,DTypeId,DPrice,DChar,DIsDelete) values(@title,@id,@price,@char,0)"; SQLiteParameter[] param = { new SQLiteParameter("@title", model.DTitle), new SQLiteParameter("@id", model.DTypeId.ToString()), new SQLiteParameter("@price", model.DPrice.ToString()), new SQLiteParameter("@char", model.DChar), }; return(SqliteHelper.ExecuteNonQuery(sql, param)); }
private void btnSave_Click(object sender, EventArgs e) { //Createa a new cuision object according to the inputs DishInfo di = new DishInfo() { DTitle = txtTitleSave.Text, DChar = txtChar.Text, DPrice = Convert.ToDecimal(txtPrice.Text), DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue) }; if (txtId.Text == "No number") { #region Add if (diBll.Add(di)) { LoadList(); } else { MessageBox.Show("Failed to add a cuision"); } #endregion } else { #region Update di.DId = int.Parse(txtId.Text); if (diBll.Update(di)) { LoadList(); } else { MessageBox.Show("Failed to add a cuision"); } #endregion } #region Restore txtId.Text = "No number"; txtTitleSave.Text = ""; txtPrice.Text = ""; txtChar.Text = ""; ddlTypeAdd.SelectedIndex = 0; #endregion }
private void btnSave_Click(object sender, EventArgs e) { //收集用户输入信息 DishInfo di = new DishInfo() { DTitle = txtTitleSave.Text, DChar = txtChar.Text, DPrice = Convert.ToDecimal(txtPrice.Text), DTypeId = Convert.ToInt32(ddlTypeAdd.SelectedValue) }; if (txtId.Text == "添加时无编号") { #region 添加 if (diBll.Add(di)) { LoadList(); } else { MessageBox.Show("逗b,怎么加的"); } #endregion } else { #region 修改 di.DId = int.Parse(txtId.Text); if (diBll.Update(di)) { LoadList(); } else { MessageBox.Show("你是猴子请来的救兵吗?"); } #endregion } #region 恢复控件 txtId.Text = "添加时无编号"; txtTitleSave.Text = ""; txtPrice.Text = ""; txtChar.Text = ""; ddlTypeAdd.SelectedIndex = 0; #endregion }
//修改 public int Update(DishInfo di) { string sql = "update DishInfo set dtitle=@title, dtypeid=@tid, dprice=@price, dchar=@dchar where did=@id"; SQLiteParameter[] ps = { new SQLiteParameter("@id", di.DId), new SQLiteParameter("@title", di.DTitle), new SQLiteParameter("@tid", di.DTypeId), new SQLiteParameter("@price", di.DPrice), new SQLiteParameter("@dchar", di.DChar) }; return(SqliteHelper.ExecuteNonQuery(sql, ps)); }
public int Update(DishInfo model) { string sql = "update DishInfo set Dtitle=@title,DTypeId=@Tid,DPrice=@price,DChar=@char where DId=@id"; SQLiteParameter[] param = { new SQLiteParameter("@title", model.DTitle), new SQLiteParameter("@Tid", model.DTypeId.ToString()), new SQLiteParameter("@price", model.DPrice.ToString()), new SQLiteParameter("@char", model.DChar), new SQLiteParameter("@id", model.DId.ToString()) }; return(SqliteHelper.ExecuteNonQuery(sql, param)); }
/// <summary> /// 插入新数据 /// </summary> /// <param name="dish"></param> /// <returns></returns> public int Insert(DishInfo dish) { string sql = "insert into dishinfo(dtitle,dtypeid,dprice,dchar,disdelete) values(@title,@typeid,@price,@char,0)"; SQLiteParameter [] sp = new SQLiteParameter[] { new SQLiteParameter("@title", dish.DTitle), new SQLiteParameter("@typeid", dish.DTypeId), new SQLiteParameter("@price", dish.DPrice), new SQLiteParameter("@char", dish.DChar), }; return(SqliteHelper.ExcuteNoQuery(sql, sp)); }