Ejemplo n.º 1
0
        /// <summary>
        /// 修改菜单信息
        /// </summary>
        /// <param name="menuInfo"></param>
        /// <returns></returns>
        public bool UpdateMenuInfo(MenuInfoModel menuInfo, bool blUpdate)
        {
            List <CommandInfo> comList = new List <CommandInfo>();
            string             cols    = "MId,MName,ParentId,ParentName,MKey,MUrl,IsTop,MOrder,MDesp";
            SqlModel           upModel = CreateSql.GetUpdateSqlAndParas(menuInfo, cols, "");

            //修改指定的菜单信息
            comList.Add(new CommandInfo()
            {
                CommandText = upModel.Sql,
                IsProc      = false,
                Paras       = upModel.SqlParaArray
            });
            if (blUpdate)
            {
                string         sqlUpdateParentName = "update MenuInfos set ParentName=@parentName where ParentId=@menuId";
                SqlParameter[] paras =
                {
                    new SqlParameter("@parentName", menuInfo.MName),
                    new SqlParameter("@menuId",     menuInfo.MId)
                };
                comList.Add(new CommandInfo()
                {
                    CommandText = sqlUpdateParentName,
                    IsProc      = false,
                    Paras       = paras
                });
            }
            return(SqlHelper.ExecuteTrans(comList));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新商品类别信息
        /// </summary>
        /// <param name="gtInfo"></param>
        /// <param name="blUpdate"></param>
        /// <returns></returns>
        public bool UpdateGoodsType(GoodsTypeInfoModel gtInfo, bool blUpdate)
        {
            List <CommandInfo> list    = new List <CommandInfo>();
            string             cols    = "GTypeId,GTypeName,ParentId,ParentName,GTypeNo,GTPYNo,GTOrder";
            SqlModel           upModel = CreateSql.GetUpdateSqlAndParas(gtInfo, cols, "");

            list.Add(new CommandInfo()
            {
                CommandText = upModel.Sql,
                IsProc      = false,
                Paras       = upModel.SqlParaArray
            });
            if (blUpdate)
            {
                SqlParameter[] paras =
                {
                    new SqlParameter("@ParentName", gtInfo.GTypeName),
                    new SqlParameter("@ParentId",   gtInfo.GTypeId)
                };
                list.Add(new CommandInfo()
                {
                    CommandText = "update GoodsTypeInfos set ParentName=@ParentName where ParentId=@ParentId",
                    IsProc      = false,
                    Paras       = paras
                });
            }
            return(SqlHelper.ExecuteTrans(list));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改单位信息 isUpdateName:单位名称是否修改
        /// </summary>
        /// <param name="guInfo"></param>
        /// <returns></returns>
        public bool UpdatGoodsUnit(GoodsUnitInfoModel guInfo, bool isUpdateName, string oldName)
        {
            string cols = "GUnitId,GUnitName,GUnitPYNo,GUnitOrder";

            if (!isUpdateName)
            {
                return(Update(guInfo, cols, ""));
            }
            else
            {
                List <CommandInfo> list    = new List <CommandInfo>();
                SqlModel           upModel = CreateSql.GetUpdateSqlAndParas(guInfo, cols, "");
                SqlParameter[]     paras   =
                {
                    new SqlParameter("@GUnit",    guInfo.GUnitName),
                    new SqlParameter("@OldGUnit", oldName),
                };
                list.Add(new CommandInfo()
                {
                    CommandText = upModel.Sql,
                    IsProc      = false,
                    Paras       = upModel.SqlParaArray
                });
                list.Add(new CommandInfo()
                {
                    CommandText = "update GoodsInfos set GUnit=@GUnit where GUnit=@OldGUnit",
                    IsProc      = false,
                    Paras       = paras
                });
                return(SqlHelper.ExecuteTrans(list));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="list"></param>
        /// <param name="strCols"></param>
        /// <returns></returns>
        public bool UpdateList(List <T> list, string strCols)
        {
            if (list == null || list.Count == 0)
            {
                return(false);
            }
            List <CommandInfo> comList = new List <CommandInfo>();

            foreach (T t in list)
            {
                SqlModel    update = CreateSql.GetUpdateSqlAndParas <T>(t, strCols, "");
                CommandInfo com    = new CommandInfo(update.Sql, false, update.SqlParaArray);
                comList.Add(com);
            }
            return(SqlHelper.ExecuteTrans(comList));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="userInfo"></param>
        /// <param name="urList"></param>
        /// <param name="urListNew"></param>
        /// <returns></returns>
        public bool UpdateUserInfo(UserInfoModel userInfo, List <UserRoleInfoModel> urList, List <UserRoleInfoModel> urListNew)
        {
            List <CommandInfo> comList  = new List <CommandInfo>();
            string             colsUser = "******";

            if (!string.IsNullOrEmpty(userInfo.UserPwd))
            {
                colsUser += ",UserPwd";
            }
            colsUser += ",UserState";
            SqlModel upUser = CreateSql.GetUpdateSqlAndParas(userInfo, colsUser, "");

            //修改用户信息
            comList.Add(new CommandInfo()
            {
                CommandText = upUser.Sql,
                IsProc      = false,
                Paras       = upUser.SqlParaArray
            });
            if (urList.Count > 0)
            {
                //删除取消的角色关系数据
                string roleIds = string.Join(",", urList.Select(ur => ur.RoleId));
                comList.Add(new CommandInfo()
                {
                    CommandText = $"delete from UserRoleInfos where RoleId not in ({roleIds}) and UserId={userInfo.UserId}",
                    IsProc      = false
                });
            }
            if (urListNew.Count > 0)
            {
                //新增新设置的角色关系
                string colsUserRole = "UserId,RoleId,Creator";
                foreach (var ur in urListNew)
                {
                    SqlModel inUserRole = CreateSql.GetInsertSqlAndParas <UserRoleInfoModel>(ur, colsUserRole, 0);
                    comList.Add(new CommandInfo()
                    {
                        CommandText = inUserRole.Sql,
                        IsProc      = false,
                        Paras       = inUserRole.SqlParaArray
                    });
                }
            }

            return(SqlHelper.ExecuteTrans(comList));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 修改信息实体
        /// </summary>
        /// <param name="t"></param>
        /// <param name="strCols">要修改的列</param>
        /// <param name="strWhere">条件 </param>
        /// <returns></returns>
        public bool Update(T t, string strCols, string strWhere, params SqlParameter[] paras)
        {
            if (t == null)
            {
                return(false);
            }
            //获取生成的sql和参数列表
            SqlModel            update    = CreateSql.GetUpdateSqlAndParas <T>(t, strCols, strWhere);
            List <SqlParameter> listParas = update.SqlParaArray.ToList();

            if (paras != null && paras.Length > 0)
            {
                listParas.AddRange(paras);
            }
            //执行sql命令
            return(SqlHelper.ExecuteNonQuery(update.Sql, 1, listParas.ToArray()) > 0);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 保存上下限设置
        /// </summary>
        /// <param name="goodsStockList"></param>
        /// <returns></returns>
        public bool SetGoodsStockUpDown(List <StoreGoodsStockInfoModel> goodsStockList)
        {
            string             upCols = "StoreGoodsId,StockUp,StockDown";
            List <CommandInfo> list   = new List <CommandInfo>();

            foreach (var gupdown in goodsStockList)
            {
                SqlModel sqlModel = CreateSql.GetUpdateSqlAndParas(gupdown, upCols, "");
                list.Add(new CommandInfo()
                {
                    CommandText = sqlModel.Sql,
                    IsProc      = false,
                    Paras       = sqlModel.SqlParaArray
                });
            }
            return(SqlHelper.ExecuteTrans(list));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 更新入库单信息
        /// </summary>
        /// <param name="stockInfo"></param>
        /// <param name="stockGoodsList"></param>
        /// <returns></returns>
        public bool UpdateStockInfo(StockStoreInfoModel stockInfo, List <StStockGoodsInfoModel> stockGoodsList)
        {
            string             cols    = "StockId,StoreId,DealPerson,Remark";
            string             sgCols  = "StockId,GoodsId,StCount,StPrice,StAmount,Remark";
            List <CommandInfo> comList = new List <CommandInfo>();
            SqlModel           upStock = CreateSql.GetUpdateSqlAndParas <StockStoreInfoModel>(stockInfo, cols, "");

            //修改入库单信息
            comList.Add(new CommandInfo()
            {
                CommandText = upStock.Sql,
                IsProc      = false,
                Paras       = upStock.SqlParaArray
            });
            //删除已移除的商品明细数据

            //商品明细编号集合字符串
            string goodsIds = string.Join(",", stockGoodsList.Select(g => g.GoodsId));

            comList.Add(new CommandInfo()
            {
                CommandText = $"delete from StStockGoodsInfos where StockId ={stockInfo.StockId} and GoodsId not in ({goodsIds})",
                IsProc      = false
            });

            //明细商品列表保存:修改、添加 两种
            foreach (StStockGoodsInfoModel sg in stockGoodsList)
            {
                if (sgDAL.ExistsGoods(stockInfo.StockId, sg.GoodsId))
                {
                    string         upSql = "update StStockGoodsInfos set StCount=@count,StPrice=@stPrice,StAmount=@stAmount,Remark=@remark where StockId=@stockId and GoodsId=@goodsId";
                    SqlParameter[] paras =
                    {
                        new SqlParameter("@stockId",  stockInfo.StockId),
                        new SqlParameter("@goodsId",  sg.GoodsId),
                        new SqlParameter("@count",    sg.StCount),
                        new SqlParameter("@stPrice",  sg.StPrice),
                        new SqlParameter("@remark",   sg.Remark),
                        new SqlParameter("@stAmount", sg.StAmount)
                    };
                    comList.Add(new CommandInfo()
                    {
                        CommandText = upSql,
                        IsProc      = false,
                        Paras       = paras
                    });
                }
                else//新增处理
                {
                    sg.StockId = stockInfo.StockId;
                    SqlModel inStStockGoods = CreateSql.GetInsertSqlAndParas <StStockGoodsInfoModel>(sg, sgCols, 0);
                    comList.Add(new CommandInfo()
                    {
                        CommandText = inStStockGoods.Sql,
                        IsProc      = false,
                        Paras       = inStStockGoods.SqlParaArray
                    });
                }
            }
            return(SqlHelper.ExecuteTrans(comList));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 更新采购单信息
        /// </summary>
        /// <param name="perchaseInfo"></param>
        /// <param name="perGoodsList"></param>
        /// <returns></returns>
        public bool UpdatePerchaseInfo(PerchaseInStoreInfoModel perchaseInfo, List <PerchaseGoodsInfoModel> perGoodsList)
        {
            string cols = "UnitId,StoreId,DealPerson,PayDesp,ThisAmount,Remark,TotalAmount,YHAmount,PerId";

            if (perchaseInfo.PayTime != null)
            {
                cols += ",PayTime,IsPayed";
            }
            if (perchaseInfo.IsPayFull == 1)
            {
                cols += ",IsPayFull";
            }
            //插入采购商品列表的列名
            string             pgCols  = "PerId,GoodsId,GUnit,Count,PerPrice,Amount,Remark";
            List <CommandInfo> comList = new List <CommandInfo>();
            SqlModel           upStock = CreateSql.GetUpdateSqlAndParas(perchaseInfo, cols, "");

            //修改采购单信息
            comList.Add(new CommandInfo()
            {
                CommandText = upStock.Sql,
                IsProc      = false,
                Paras       = upStock.SqlParaArray
            });
            //删除已移除的商品明细数据

            //商品明细编号集合字符串
            string goodsIds = string.Join(",", perGoodsList.Select(g => g.GoodsId));

            comList.Add(new CommandInfo()
            {
                CommandText = $"delete from PerchaseGoodsInfos where PerId ={perchaseInfo.PerId} and GoodsId not in ({goodsIds})",
                IsProc      = false
            });

            //明细商品列表保存:修改、添加 两种
            foreach (PerchaseGoodsInfoModel sg in perGoodsList)
            {
                if (pgDAL.ExistsGoods(perchaseInfo.PerId, sg.GoodsId))
                {
                    string         upSql = "update PerchaseGoodsInfos set Count=@count,PerPrice=@perPrice,Amount=@Amount,Remark=@remark where PerId=@perId and GoodsId=@goodsId";
                    SqlParameter[] paras =
                    {
                        new SqlParameter("@perId",    perchaseInfo.PerId),
                        new SqlParameter("@goodsId",  sg.GoodsId),
                        new SqlParameter("@count",    sg.Count),
                        new SqlParameter("@perPrice", sg.PerPrice),
                        new SqlParameter("@remark",   sg.Remark),
                        new SqlParameter("@Amount",   sg.Amount)
                    };
                    comList.Add(new CommandInfo()
                    {
                        CommandText = upSql,
                        IsProc      = false,
                        Paras       = paras
                    });
                }
                else//新增处理
                {
                    sg.PerId = perchaseInfo.PerId;
                    SqlModel inStStockGoods = CreateSql.GetInsertSqlAndParas(sg, pgCols, 0);
                    comList.Add(new CommandInfo()
                    {
                        CommandText = inStStockGoods.Sql,
                        IsProc      = false,
                        Paras       = inStStockGoods.SqlParaArray
                    });
                }
            }
            return(SqlHelper.ExecuteTrans(comList));
        }