コード例 #1
0
        /// <summary>
        /// 根据条件获取模板列表
        /// </summary>
        /// <param name="model">ModuleTableModel实体</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageCount"></param>
        /// <param name="ord"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public static DataTable GetTableViewModelList(ModuleTableModel model, int pageIndex, int pageCount, string ord, ref int totalCount)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.AppendLine(" select m.ID,m.TableID,m.ModuleType,m.UseStatus,");
            strSql.AppendLine(" case m.ModuleType when 0 then '添加模板' end as ModuleTypeText,");
            strSql.AppendLine(" case m.UseStatus when 0 then '停用' when 1 then '启用' end as UseStatusText, ");
            strSql.AppendLine(" c.AliasTableName as TableName ");
            strSql.AppendLine(" from defdba.ModuleTable m ");
            strSql.AppendLine(" left join defdba.customtable c on m.TableID=c.ID ");
            strSql.AppendLine(" where m.CompanyCD=@CompanyCD ");

            ArrayList arr = new ArrayList();

            arr.Add(new SqlParameter("@CompanyCD", model.CompanyCD));

            if (!string.IsNullOrEmpty(model.TableID))
            {
                strSql.AppendLine(" and m.TableID=@ID ");
                arr.Add(new SqlParameter("@ID", model.TableID));
            }
            if (model.ModuleType != null)
            {
                strSql.AppendLine(" and m.ModuleType=@ModuleType ");
                arr.Add(new SqlParameter("@ModuleType", model.ModuleType));
            }
            if (model.UseStatus != null)
            {
                strSql.AppendLine(" and m.UseStatus=@UseStatus ");
                arr.Add(new SqlParameter("@UseStatus", model.UseStatus));
            }
            return(SqlHelper.CreateSqlByPageExcuteSqlArr(strSql.ToString(), pageIndex, pageCount, ord, arr, ref totalCount));
        }
コード例 #2
0
        /// <summary>
        /// 保存模板
        /// </summary>
        /// <param name="tbModel">ModuleTableModel模板实体</param>
        /// <param name="strMsg"></param>
        public static int SaveTableModel(ModuleTableModel tbModel, out string strMsg)
        {
            StringBuilder strSql = new StringBuilder();

            strMsg = "";
            int tbID = 0;

            if (!IsRepeatedModule(tbModel.TableID, "0"))
            {
                TransactionManager tran = new TransactionManager();
                tran.BeginTransaction();
                try
                {
                    strSql.AppendLine(" insert into defdba.ModuleTable (CompanyCD,ModuleContent,TableID,ModuleType,UseStatus)");
                    strSql.AppendLine(" values(@CompanyCD,@ModuleContent,@TableID,@ModuleType,@UseStatus)");
                    strSql.AppendLine(" ;select @@IDENTITY ");
                    SqlParameter[] param =
                    {
                        new SqlParameter("@CompanyCD",     tbModel.CompanyCD),
                        new SqlParameter("@ModuleContent", tbModel.ModuleContent),
                        new SqlParameter("@TableID",       tbModel.TableID),
                        new SqlParameter("@ModuleType",    tbModel.ModuleType),
                        new SqlParameter("@UseStatus",     tbModel.UseStatus)
                    };
                    foreach (SqlParameter para in param)
                    {
                        if (para.Value == null)
                        {
                            para.Value = DBNull.Value;
                        }
                    }
                    tbID = Convert.ToInt32(SqlHelper.ExecuteScalar(strSql.ToString(), param));
                    tran.Commit();
                    strMsg = "保存成功!";
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    strMsg = "保存失败,请联系系统管理员!";
                    throw ex;
                }
            }
            else
            {
                strMsg = "保存失败,该表的模板已定义!";
            }

            return(tbID);
        }
コード例 #3
0
        /// <summary>
        ///  修改模板
        /// </summary>
        /// <param name="tbModel">ModuleTableModel模板实体</param>
        /// <param name="strMsg"></param>
        public static bool UpdateTableModel(ModuleTableModel tbModel, out string strMsg)
        {
            StringBuilder strSql = new StringBuilder();

            strMsg = "";
            bool isSuc = false;

            if (!IsRepeatedModule(tbModel.TableID, tbModel.ID.ToString()))
            {
                TransactionManager tran = new TransactionManager();
                tran.BeginTransaction();
                try
                {
                    strSql.AppendLine(" update defdba.ModuleTable set CompanyCD=@CompanyCD,ModuleContent=@ModuleContent,TableID=@TableID,");
                    strSql.AppendLine(" ModuleType=@ModuleType,UseStatus=@UseStatus ");
                    strSql.AppendLine(" where ID=@ID ");
                    SqlParameter[] param =
                    {
                        new SqlParameter("@ID",            tbModel.ID),
                        new SqlParameter("@CompanyCD",     tbModel.CompanyCD),
                        new SqlParameter("@ModuleContent", tbModel.ModuleContent),
                        new SqlParameter("@TableID",       tbModel.TableID),
                        new SqlParameter("@ModuleType",    tbModel.ModuleType),
                        new SqlParameter("@UseStatus",     tbModel.UseStatus)
                    };
                    SqlHelper.ExecuteScalar(strSql.ToString(), param);
                    tran.Commit();
                    strMsg = "修改成功!";
                    isSuc  = true;
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    strMsg = "修改失败,请联系系统管理员!";
                    isSuc  = false;
                    throw ex;
                }
            }
            else
            {
                strMsg = "修改失败,该表的模板已定义!";
                isSuc  = false;
            }

            return(isSuc);
        }
コード例 #4
0
 /// <summary>
 /// 根据条件获取模板列表
 /// </summary>
 /// <param name="model"></param>
 /// <param name="pageIndex"></param>
 /// <param name="pageCount"></param>
 /// <param name="ord"></param>
 /// <param name="totalCount"></param>
 /// <returns></returns>
 public static DataTable GetTableViewModelList(ModuleTableModel model, int pageIndex, int pageCount, string ord, ref int totalCount)
 {
     return(CreateTableViewModelDBHelper.GetTableViewModelList(model, pageIndex, pageCount, ord, ref totalCount));
 }
コード例 #5
0
 /// <summary>
 ///  修改模板
 /// </summary>
 /// <param name="tbModel">ModuleTableModel模板实体</param>
 /// <param name="strMsg"></param>
 public static bool UpdateTableModel(ModuleTableModel tbModel, out string strMsg)
 {
     return(CreateTableViewModelDBHelper.UpdateTableModel(tbModel, out strMsg));
 }
コード例 #6
0
 /// <summary>
 /// 保存模板
 /// </summary>
 /// <param name="tbModel">ModuleTableModel模板实体</param>
 /// <param name="strMsg"></param>
 public static int SaveTableModel(ModuleTableModel tbModel, out string strMsg)
 {
     return(CreateTableViewModelDBHelper.SaveTableModel(tbModel, out strMsg));
 }