Beispiel #1
0
        /// <summary>
        /// 保存批次规则设置
        /// </summary>
        /// <param name="model">BachNoRuleSet实体</param>
        /// <param name="strMsg">返回信息</param>
        /// <returns>规则ID</returns>
        public static int SaveBatchRule(BatchNoRuleSet model, out string strMsg)
        {
            int ruleID = 0;

            strMsg = "";
            StringBuilder strSql = new StringBuilder();

            if (!IsExisted(model.CompanyCD))
            {
                TransactionManager tran = new TransactionManager();
                tran.BeginTransaction();
                try
                {
                    strSql.AppendLine(" insert into officedba.BatchRule ");
                    strSql.AppendLine(" (CompanyCD,RuleName,RulePrefix,RuleDateType,RuleNoLen,LastNo,RuleExample,");
                    strSql.AppendLine(" Remark,IsDefault,UsedStatus,ModifiedDate,ModifiedUserID) values");
                    strSql.AppendLine(" (@CompanyCD,@RuleName,@RulePrefix,@RuleDateType,@RuleNoLen,@LastNo,@RuleExample,");
                    strSql.AppendLine(" @Remark,@IsDefault,@UsedStatus,getdate(),@ModifiedUserID)");
                    strSql.AppendLine(" ;select @@IDENTITY ");
                    SqlParameter[] param =
                    {
                        new SqlParameter("@CompanyCD",      model.CompanyCD),
                        new SqlParameter("@RuleName",       model.RuleName),
                        new SqlParameter("@RulePrefix",     model.RulePrefix),
                        new SqlParameter("@RuleDateType",   model.RuleDateType),
                        new SqlParameter("@RuleNoLen",      model.RuleNoLen),
                        new SqlParameter("@LastNo",         model.LastNo),
                        new SqlParameter("@RuleExample",    model.RuleExample),
                        new SqlParameter("@Remark",         model.Remark),
                        new SqlParameter("@IsDefault",      model.IsDefault),
                        new SqlParameter("@UsedStatus",     model.UsedStatus),
                        new SqlParameter("@ModifiedUserID", model.ModifiedUserID)
                    };

                    foreach (SqlParameter para in param)
                    {
                        if (para.Value == null)
                        {
                            para.Value = DBNull.Value;
                        }
                    }
                    ruleID = Convert.ToInt32(SqlHelper.ExecuteScalar(strSql.ToString(), param));
                    tran.Commit();
                    strMsg = "保存成功!";
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    strMsg = "保存失败,请联系系统管理员!";
                    throw ex;
                }
            }
            else
            {
                strMsg = "保存失败,已存在批次规则!";
            }

            return(ruleID);
        }
Beispiel #2
0
        /// <summary>
        ///  修改批次规则设置
        /// </summary>
        /// <param name="tbModel">ModuleTableModel模板实体</param>
        /// <param name="strMsg"></param>
        public static bool UpdateBatchRule(BatchNoRuleSet model, out string strMsg)
        {
            StringBuilder strSql = new StringBuilder();

            strMsg = "";
            bool isSuc = false;
            TransactionManager tran = new TransactionManager();

            tran.BeginTransaction();
            try
            {
                strSql.AppendLine(" update officedba.BatchRule set ");
                strSql.AppendLine(" RuleName=@RuleName,RulePrefix=@RulePrefix,RuleDateType=@RuleDateType,RuleNoLen=@RuleNoLen,");
                strSql.AppendLine(" RuleExample=@RuleExample,Remark=@Remark,IsDefault=@IsDefault,");
                strSql.AppendLine(" UsedStatus=@UsedStatus,ModifiedDate=getdate(),ModifiedUserID=@ModifiedUserID ");
                strSql.AppendLine(" where ID=@ID and CompanyCD=@CompanyCD ");
                SqlParameter[] param =
                {
                    new SqlParameter("@ID",             model.ID),
                    new SqlParameter("@CompanyCD",      model.CompanyCD),
                    new SqlParameter("@RuleName",       model.RuleName),
                    new SqlParameter("@RulePrefix",     model.RulePrefix),
                    new SqlParameter("@RuleDateType",   model.RuleDateType),
                    new SqlParameter("@RuleNoLen",      model.RuleNoLen),
                    //new SqlParameter("@LastNo",model.LastNo),
                    new SqlParameter("@RuleExample",    model.RuleExample),
                    new SqlParameter("@Remark",         model.Remark),
                    new SqlParameter("@IsDefault",      model.IsDefault),
                    new SqlParameter("@UsedStatus",     model.UsedStatus),
                    new SqlParameter("@ModifiedUserID", model.ModifiedUserID)
                };
                foreach (SqlParameter para in param)
                {
                    if (para.Value == null)
                    {
                        para.Value = DBNull.Value;
                    }
                }
                SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), param);
                tran.Commit();
                strMsg = "保存成功!";
                isSuc  = true;
            }
            catch (Exception ex)
            {
                tran.Rollback();
                strMsg = "保存失败,请联系系统管理员!";
                isSuc  = false;
                throw ex;
            }

            return(isSuc);
        }
Beispiel #3
0
 /// <summary>
 ///  修改批次规则设置
 /// </summary>
 /// <param name="tbModel">ModuleTableModel模板实体</param>
 /// <param name="strMsg"></param>
 public static bool UpdateBatchRule(BatchNoRuleSet model, out string strMsg)
 {
     return(BatchNoRuleSetDBHelper.UpdateBatchRule(model, out strMsg));
 }
Beispiel #4
0
 /// <summary>
 /// 保存批次规则设置
 /// </summary>
 /// <param name="model">BachNoRuleSet实体</param>
 /// <param name="strMsg">返回信息</param>
 /// <returns>规则ID</returns>
 public static int SaveBatchRule(BatchNoRuleSet model, out string strMsg)
 {
     return(BatchNoRuleSetDBHelper.SaveBatchRule(model, out strMsg));
 }