/// <summary> /// 修改自定义表单 /// </summary> /// <param name="model"></param> /// <param name="sonModel"></param> /// <param name="strMsg"></param> /// <returns></returns> public static bool EditTable(CustomTableModel model, List<StructTable> sonModel, out string strMsg) { bool isSucc = false;//是否添加成功 strMsg = ""; string strSql = "delete from defdba.StructTable where TableID=@TableID "; SqlParameter[] paras = { new SqlParameter("@TableID", model.ID) }; TransactionManager tran = new TransactionManager(); tran.BeginTransaction(); try { EidtCustomTable(model, tran); SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), paras); AddStructTable(sonModel, Convert.ToInt32(model.ID), tran); tran.Commit(); isSucc = true; strMsg = "保存成功!"; } catch (Exception ex) { tran.Rollback(); strMsg = "保存失败,请联系系统管理员!"; throw ex; } return isSucc; }
/// <summary> /// 添加自定义表单 /// </summary> /// <returns></returns> public static int AddTable(CustomTableModel model, List<StructTable> sonModel, out string strMsg) { int TableID = 0; strMsg = ""; //判断单据编号是否存在 if (!Exists(model.CompanyCD, model.CustomTableName)) { TransactionManager tran = new TransactionManager(); tran.BeginTransaction(); try { TableID = AddCustomTable(model, tran); AddStructTable(sonModel, TableID, tran); tran.Commit(); strMsg = "保存成功!"; } catch (Exception ex) { tran.Rollback(); strMsg = "保存失败,请联系系统管理员!"; throw ex; } } else { strMsg = "该表名已被使用,请输入未使用的表名!"; } return TableID; }
/// <summary> /// 修改表信息 /// </summary> /// <param name="model"></param> /// <param name="tran"></param> public static void EidtCustomTable(CustomTableModel model, TransactionManager tran) { StringBuilder strSql = new StringBuilder(); strSql.Append("update defdba.CustomTable set "); strSql.Append("CompanyCD=@CompanyCD,"); strSql.Append("CustomTableName=@CustomTableName,"); strSql.Append("ParentID=@ParentID,"); strSql.Append("ColumnNumber=@ColumnNumber,"); strSql.Append("AliasTableName=@AliasTableName,"); strSql.Append("totalFlag=@totalFlag,"); strSql.Append("IsDic=@IsDic"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4), new SqlParameter("@CompanyCD", SqlDbType.VarChar,50), new SqlParameter("@CustomTableName", SqlDbType.VarChar,100), new SqlParameter("@ParentID", SqlDbType.Int,4), new SqlParameter("@ColumnNumber", SqlDbType.Int,4), new SqlParameter("@AliasTableName", SqlDbType.VarChar,300), new SqlParameter("@totalFlag", SqlDbType.Int), new SqlParameter("@IsDic", SqlDbType.Int)}; parameters[0].Value = model.ID; parameters[1].Value = model.CompanyCD; parameters[2].Value = model.CustomTableName; parameters[3].Value = model.ParentId; parameters[4].Value = model.ColumnNumber; parameters[5].Value = model.AliasTableName; parameters[6].Value = model.totalFlag; parameters[7].Value = model.IsDic; SqlHelper.ExecuteNonQuery(tran.Trans, CommandType.Text, strSql.ToString(), parameters); }
/// <summary> /// 添加表信息 /// </summary> /// <param name="model"></param> /// <param name="tran"></param> /// <returns></returns> public static int AddCustomTable(CustomTableModel model, TransactionManager tran) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into defdba.CustomTable("); strSql.Append("CompanyCD,CustomTableName,AliasTableName,ParentId,ColumnNumber,IsDic,totalFlag)"); strSql.Append(" values ("); strSql.Append("@CompanyCD,@CustomTableName,@AliasTableName,@ParentId,@ColumnNumber,@IsDic,@totalFlag)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CompanyCD", SqlDbType.VarChar,50), new SqlParameter("@CustomTableName", SqlDbType.VarChar,100), new SqlParameter("@AliasTableName", SqlDbType.VarChar,300), new SqlParameter("@ParentId", SqlDbType.Int,4), new SqlParameter("@ColumnNumber", SqlDbType.Int,4), new SqlParameter("@IsDic", SqlDbType.Int,4), new SqlParameter("@totalFlag", SqlDbType.Int,4)}; parameters[0].Value = model.CompanyCD; parameters[1].Value = model.CustomTableName; parameters[2].Value = model.AliasTableName; parameters[3].Value = model.ParentId; parameters[4].Value = model.ColumnNumber; parameters[5].Value = model.IsDic; parameters[6].Value = model.totalFlag; return Convert.ToInt32(SqlHelper.ExecuteScalar(strSql.ToString(), parameters)); }
/// <summary> /// 修改自定义表单 /// </summary> /// <param name="model"></param> /// <param name="sonModel"></param> /// <param name="strMsg"></param> /// <returns></returns> public static bool EditTable(CustomTableModel model, List<StructTable> sonModel, out string strMsg) { return DefFormDBHelper.EditTable(model, sonModel, out strMsg); }