private bool IsExists(int goodsID)
        {
            IList <ICriterion> qryList = new List <ICriterion>();

            qryList.Add(Expression.Eq("ParentEquipmentID", DishesID));
            qryList.Add(Expression.Eq("EquipmentID", goodsID));
            qryList.Add(Expression.Eq("EquipmentType", TypeID.ToString()));

            EquipmentAssortInfo objInfo = Core.Container.Instance.Resolve <IServiceEquipmentAssortInfo>().GetEntityByFields(qryList);

            return(objInfo != null ? true : false);
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string             sqlWhere = string.Empty;
            IList <ICriterion> qryList  = new List <ICriterion>();

            //获取物品规格信息
            qryList.Add(Expression.Eq("EquipmentTypeID", DishesID));
            Order[] orderList = new Order[1];
            Order   orderli   = new Order("ID", true);

            orderList[0] = orderli;
            IList <EquipmentInfo> eqpList = Core.Container.Instance.Resolve <IServiceEquipmentInfo>().GetAllByKeys(qryList, orderList);

            //获取物品配套辅材信息
            qryList = new List <ICriterion>();
            qryList.Add(Expression.Eq("ParentEquipmentID", DishesID));
            qryList.Add(Expression.Eq("EquipmentType", "1"));
            IList <EquipmentAssortInfo> list = Core.Container.Instance.Resolve <IServiceEquipmentAssortInfo>().GetAllByKeys(qryList, orderList);

            foreach (EquipmentInfo eqpObj in eqpList)
            {
                //删除物品规格已有配套辅材信息
                sqlWhere = string.Format(" ParentEquipmentID={0} and EquipmentType='2' ", eqpObj.ID);
                Core.Container.Instance.Resolve <IServiceEquipmentAssortInfo>().DelelteAll(sqlWhere);
                foreach (EquipmentAssortInfo obj in list)
                {
                    //添加新的配套材料信息
                    EquipmentAssortInfo newObj = new EquipmentAssortInfo();
                    newObj.EquipmentCount    = obj.EquipmentCount;
                    newObj.AssortCount       = obj.AssortCount;
                    newObj.EquipmentID       = obj.EquipmentID;
                    newObj.EquipmentType     = "2";
                    newObj.Remark            = obj.Remark;
                    newObj.IsInCalcNumber    = obj.IsInCalcNumber;
                    newObj.IsInCalcPrice     = obj.IsInCalcPrice;
                    newObj.IsOutCalcNumber   = obj.IsOutCalcNumber;
                    newObj.IsOutCalcPrice    = obj.IsOutCalcPrice;
                    newObj.ParentEquipmentID = eqpObj.ID;
                    Core.Container.Instance.Resolve <IServiceEquipmentAssortInfo>().Create(newObj);
                }
            }
            Alert.ShowInTop("物品规格信息中配套材料信息同步更新完成!", MessageBoxIcon.Information);
        }
        protected void Grid1_AfterEdit(object sender, GridAfterEditEventArgs e)
        {
            Dictionary <int, Dictionary <string, object> > modifiedDict = Grid1.GetModifiedDict();

            foreach (int rowIndex in modifiedDict.Keys)
            {
                int rowID = Convert.ToInt32(Grid1.DataKeys[rowIndex][0]);
                EquipmentAssortInfo objInfo = Core.Container.Instance.Resolve <IServiceEquipmentAssortInfo>().GetEntity(rowID);
                if (modifiedDict[rowIndex].Keys.Contains("AssortCount"))
                {
                    objInfo.AssortCount = Convert.ToDecimal(modifiedDict[rowIndex]["AssortCount"]);
                }
                if (modifiedDict[rowIndex].Keys.Contains("EquipmentCount"))
                {
                    objInfo.EquipmentCount = Convert.ToDecimal(modifiedDict[rowIndex]["EquipmentCount"]);
                }
                if (modifiedDict[rowIndex].Keys.Contains("IsOutCalcNumber"))
                {
                    objInfo.IsOutCalcNumber = Convert.ToInt32(modifiedDict[rowIndex]["IsOutCalcNumber"]);
                }
                if (modifiedDict[rowIndex].Keys.Contains("IsOutCalcPrice"))
                {
                    objInfo.IsOutCalcPrice = Convert.ToInt32(modifiedDict[rowIndex]["IsOutCalcPrice"]);
                }
                if (modifiedDict[rowIndex].Keys.Contains("IsInCalcNumber"))
                {
                    objInfo.IsInCalcNumber = Convert.ToInt32(modifiedDict[rowIndex]["IsInCalcNumber"]);
                }
                if (modifiedDict[rowIndex].Keys.Contains("IsInCalcPrice"))
                {
                    objInfo.IsInCalcPrice = Convert.ToInt32(modifiedDict[rowIndex]["IsInCalcPrice"]);
                }


                Core.Container.Instance.Resolve <IServiceEquipmentAssortInfo>().Update(objInfo);
            }

            BindGrid();
        }
        private void SaveItem()
        {
            // 从每个选中的行中获取ID(在Grid1中定义的DataKeyNames)
            List <int>          ids        = GetSelectedDataKeyIDs(Grid1);
            EquipmentAssortInfo dbEntity   = new EquipmentAssortInfo();
            EquipmentInfo       dishesInfo = Core.Container.Instance.Resolve <IServiceEquipmentInfo>().GetEntity(DishesID);

            // 执行数据库操作
            foreach (int ID in ids)
            {
                //判断是否已经添加改配料物品
                if (!IsExists(ID))
                {
                    dbEntity                   = new EquipmentAssortInfo();
                    dbEntity.EquipmentID       = ID;
                    dbEntity.EquipmentType     = TypeID.ToString();
                    dbEntity.ParentEquipmentID = DishesID;
                    dbEntity.AssortCount       = 1;
                    dbEntity.EquipmentCount    = 1;
                    Core.Container.Instance.Resolve <IServiceEquipmentAssortInfo>().Create(dbEntity);
                }
            }
        }