Beispiel #1
0
        public void DeleteItemStandards(int standardkey)
        {
            try
            {
                DianDianEntities db = new DianDianEntities();
                item_standard    ic = new item_standard();
                ic.standardkey = standardkey;

                db.item_standard.Attach(ic);
                db.item_standard.Remove(ic);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                log.Error("DeleteItemStandards error. msg=" + e.Message);
                throw;
            }
        }
Beispiel #2
0
        //23. 修改菜品菜品规格接口
        public void EditItemStandards(int standardkey, int itemkey, string standardName, decimal price, sbyte state)
        {
            try
            {
                DianDianEntities db = new DianDianEntities();
                if (standardkey != 0)
                {
                    item_standard ic = db.item_standard.Find(standardkey);
                    ic.itemKey      = itemkey;
                    ic.standardname = standardName;
                    ic.sprice       = price;
                    ic.state        = state;

                    db.item_standard.Attach(ic);
                    var stateEntity = ((IObjectContextAdapter)db).ObjectContext.ObjectStateManager.GetObjectStateEntry(ic);
                    stateEntity.SetModifiedProperty("itemKey");
                    stateEntity.SetModifiedProperty("standardname");
                    stateEntity.SetModifiedProperty("sprice");
                    stateEntity.SetModifiedProperty("state");
                    db.SaveChanges();
                }
                else
                {
                    item_standard ic = new item_standard();
                    ic.itemKey      = itemkey;
                    ic.standardname = standardName;
                    ic.sprice       = price;
                    ic.state        = state;

                    db.item_standard.Add(ic);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                log.Error("EditItemStandards error. msg=" + e.Message);
                throw;
            }
        }