Ejemplo n.º 1
0
 //保存列字段信息
 public void SaveColumn()
 {
     NameValueCollection Params = HttpContext.Request.Form;//参数
     Column column = new Column();
     column.Author = User.Identity.Name;
     column.TablesCode = new Guid(Params["tablesCode"]);
     column.Owner = Params["owner"];
     column.Name = Params["name"];
     column.Type = Params["type"];
     column.Bewrite = Params["bewrite"];
     column.FieldState = int.Parse(Params["fieldState"]);
     column.HideAuthor = Params["hideAuthor"];
     column.HideTime = DateTime.Now;//默认为空
     string result = string.Empty;
     if (Params["code"] != null)
     {
         column.Code = new Guid(Params["code"]);
         result = DColumn.Update(column) != null ? "{HasError:false,msg:'列字段编辑成功!'}" : "{HasError:true,msg:'列字段编辑失败,请稍候再试!'}";
     }
     else
     {
         column.Code = Guid.NewGuid();
         result = DColumn.Add(column) != null ? "{HasError:false,msg:'列字段创建成功!'}" : "{HasError:true,msg:'列字段创建失败,请稍候再试!'}";
     }
     Response.Write(result);
     Response.End();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 根据(副表同步主表)说明
 /// </summary>
 /// <param name="Params">参数</param>
 /// <param name="tablesCode">表编码</param>
 /// <param name="TablesName">表名</param>
 /// <param name="SqlConnection">链接字符串</param>
 /// <param name="columnDt">主表</param>
 /// <param name="columnlist">附表</param>
 private void SynchronousChief(NameValueCollection Params,Guid tablesCode, string TablesName, string SqlConnection, DataTable columnDt, IList<Column> columnlist)
 {
     string SynchronousSQL = string.Empty;
     for (int i = 0; i < columnlist.Count; i++)
     {
         int columnNumber = 0;//记录主表与副表的交集数
         for (int j = 0; j < columnDt.Rows.Count; j++)
         {
             //同步主表说明的SQL
             if (columnDt.Rows[j]["columnsName"].ToString() == columnlist[i].Name && columnlist[i].Bewrite != ""
                 && (columnDt.Rows[j]["remark"].ToString() == "" || columnDt.Rows[j]["remark"].ToString() != columnlist[i].Bewrite))
             {
                 SynchronousSQL += string.Format("execute {4} N'MS_Description',N'{3}',N'SCHEMA',N'{0}',N'table',N'{1}',N'column',N'{2}';",
                     columnlist[i].Owner, TablesName, columnlist[i].Name, columnlist[i].Bewrite,
                     columnDt.Rows[j]["remark"].ToString() == "" ? "sp_addextendedproperty" : "sp_updateextendedproperty");
             }
             //同步副表说明
             if (columnDt.Rows[j]["columnsName"].ToString() == columnlist[i].Name && columnlist[i].Bewrite == ""
                 && columnDt.Rows[j]["remark"].ToString() != "")
             {
                 Column column = new Column();
                 column.Author = User.Identity.Name;
                 column.TablesCode = tablesCode;
                 column.Owner = columnlist[i].Owner;
                 column.Name = columnlist[i].Name;
                 column.Type = columnlist[i].Type;
                 column.Bewrite = columnDt.Rows[j]["remark"].ToString();
                 column.FieldState = 1;
                 column.HideAuthor = string.Empty;
                 column.HideTime = DateTime.Now;
                 column.Code = columnlist[i].Code;
                 DColumn.Update(column);
             }
             if (columnDt.Rows[j]["columnsName"].ToString() == columnlist[i].Name)
             {
                 columnNumber++;
             }
         }
         //附表存在作废字段
         if (columnNumber == 0)
         {
             Column column = new Column();
             column.Author = User.Identity.Name;
             column.TablesCode = new Guid(Params["tablesCode"]);
             column.Owner = columnlist[i].Owner;
             column.Name = columnlist[i].Name;
             column.Type = columnlist[i].Type;
             column.Bewrite = columnlist[i].Bewrite;
             column.FieldState = 0;
             column.HideAuthor = User.Identity.Name;
             column.HideTime = DateTime.Now;
             column.Code = columnlist[i].Code;
             DColumn.Update(column);
         }
     }
     SQLHelper.ExecuteSql(SqlConnection, SynchronousSQL);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 根据(主表同步副表)字段
 /// </summary>
 /// <param name="Params">参数</param>
 /// <param name="tablesCode">表编码</param>
 /// <param name="columnDt">主表</param>
 /// <param name="columnlist">副表</param>
 private void SynchronousSide(NameValueCollection Params, Guid tablesCode, DataTable columnDt, IList<Column> columnlist)
 {
     for (int k = 0; k < columnDt.Rows.Count; k++)
     {
         int columnNumber = 0;//记录主表与副表的交集数
         for (int q = 0; q < columnlist.Count; q++)
         {
             if (columnDt.Rows[k]["columnsName"].ToString() == columnlist[q].Name)
             {
                 columnNumber++;
             }
         }
         //主表存在新的列字段
         if (columnNumber == 0)
         {
             Column column = new Column();
             column.Author = User.Identity.Name;
             column.TablesCode = tablesCode;
             column.Owner = columnDt.Rows[k]["owner"].ToString();
             column.Name = columnDt.Rows[k]["columnsName"].ToString();
             column.Type = columnDt.Rows[k]["columnType"].ToString();
             column.Bewrite = columnDt.Rows[k]["remark"].ToString();
             column.FieldState = 1;
             column.HideAuthor = string.Empty;
             column.HideTime = DateTime.Now;
             column.Code = Guid.NewGuid();
             DColumn.Add(column);
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 批量添加列字段信息
 /// </summary>
 /// <param name="resultT">执行结果</param>
 /// <param name="table">表信息</param>
 /// <param name="dt">列字段信息</param>
 /// <returns></returns>
 private bool BatchAddColumn(bool resultT, Tables table, DataTable dt)
 {
     for (int j = 0; j < dt.Rows.Count; j++)
     {
         //列名是否重复,重复则不执行保存操作
         string columnName = dt.Rows[j]["columnsName"].ToString();
         if (!DColumn.RepeatColumnName(columnName, table.Code, User.Identity.Name))
         {
             Column column = new Column();
             column.Author = User.Identity.Name;
             column.TablesCode = table.Code;
             column.Owner = dt.Rows[j]["owner"].ToString();
             column.Name = columnName;
             column.Type = dt.Rows[j]["columnType"].ToString();
             column.Bewrite = dt.Rows[j]["remark"].ToString();
             column.FieldState = 1;
             column.HideAuthor = "";
             column.HideTime = DateTime.Now;//默认为空
             column.Code = Guid.NewGuid();
             DColumn.Add(column);//添加列
             resultT = true;
         }
     }
     return resultT;
 }