/// <summary>
 ///添加表
 /// </summary>
 /// <returns></returns>
 public string AddTabName(string tableName, int UserId)
 {
     model.pbxdatasourceDataContext context = new model.pbxdatasourceDataContext();
     try
     {
         string check = @"select count(*)  from syscolumns where id=object_id('" + tableName + "')";
         if (DbHelperSQL.Query(check).Tables[0].Rows[0][0].ToString() == "0")
         {
             return("该表不存在!");
         }
         else
         {
             var p = (from c in context.tableFiledPerssion where c.tableName == tableName select c.tableName).FirstOrDefault();
             if (p == null)
             {
                 model.tableFiledPerssion tt = new model.tableFiledPerssion()
                 {
                     tableName       = tableName,
                     tableLevel      = 0,
                     tableNameState  = 1,
                     tableFiledState = 1,
                 };
                 context.tableFiledPerssion.InsertOnSubmit(tt);
                 context.SubmitChanges();
                 string sql = @"insert into tableFiledPerssion(tableName,tableLevel) select name,(select id from tableFiledPerssion where tableName='" + tableName + "') from sys.syscolumns where id =object_id('" + tableName + "')";
                 DbHelperSQL.ExecuteSql(sql);
                 errordal.InsertErrorlog(new model.errorlog()
                 {
                     errorSrc        = "pbxdata.dal->tablefiledPerssiondal->AddTabName()",
                     ErrorMsg        = "添加",
                     errorTime       = DateTime.Now,
                     operation       = 2,
                     errorMsgDetails = "添加表->" + tableName,
                     UserId          = UserId,
                 });
             }
             else
             {
                 return("该表已存在!");
             }
             return("");
         }
     }
     catch (Exception ex)
     {
         errordal.InsertErrorlog(new model.errorlog()
         {
             errorSrc        = "pbxdata.dal->tablefiledPerssiondal->AddTabName()",
             ErrorMsg        = "添加",
             errorTime       = DateTime.Now,
             operation       = 1,
             errorMsgDetails = "添加表失败->" + tableName + "->" + ex.Message,
             UserId          = UserId,
         });
         return("添加失败!");
     }
 }
示例#2
0
        public void getUserFiled(List <int> listMenuIdC, List <int> listFunId)
        {
            string s = string.Empty;

            foreach (int item in listMenuIdC)
            {
                s += item + ",";
            }
            s = s.Length > 0 ? s.Remove(s.Length - 1, 1) : s;

            string s1 = string.Empty;

            foreach (int item in listFunId)
            {
                s1 += item + ",";
            }
            s1 = s1.Length > 0 ? s1.Remove(s1.Length - 1, 1) : s1;
            IDataParameter[] iparaFiled = new IDataParameter[] {
                new SqlParameter("roleId", SqlDbType.Int, 4),
                new SqlParameter("menuId", SqlDbType.NVarChar, 5000),
                new SqlParameter("funId", SqlDbType.NVarChar, 5000),
            };
            iparaFiled[0].Value = us.User.personaId;
            iparaFiled[1].Value = s;
            iparaFiled[2].Value = s1;
            List <int> listFiledId = new List <int>();

            model.tableFiledPerssion  filedMd  = new model.tableFiledPerssion();
            bll.tableFiledPerssionbll filedBll = new bll.tableFiledPerssionbll();

            List <model.tableFiledPerssion> listFiled = filedBll.getTable(iparaFiled, "tableFiledSelect");

            foreach (var item in listFiled)
            {
                listFiledId.Add(item.Id);
            }
            if (listFiled.Count == 0)
            {
                listFiledId.Add(9999);
            }
            us.FiledId = listFiledId;
        }
 /// <summary>
 ///添加列
 /// </summary>
 /// <returns></returns>
 public string AddFiledName(string tableName, string tableLevel, int UserId)
 {
     model.pbxdatasourceDataContext context = new model.pbxdatasourceDataContext();
     try
     {
         int tableLevels = Convert.ToInt32(tableLevel);
         var p           = (from c in context.tableFiledPerssion where c.tableName == tableName && c.tableLevel == tableLevels select c.tableName).FirstOrDefault();
         if (p == null)
         {
             model.tableFiledPerssion tt = new model.tableFiledPerssion()
             {
                 tableName       = tableName,
                 tableLevel      = tableLevels,
                 tableNameState  = 1,
                 tableFiledState = 1,
             };
             context.tableFiledPerssion.InsertOnSubmit(tt);
             context.SubmitChanges();
             errordal.InsertErrorlog(new model.errorlog()
             {
                 errorSrc        = "pbxdata.dal->tablefiledPerssiondal->AddFiledName()",
                 ErrorMsg        = "添加",
                 errorTime       = DateTime.Now,
                 operation       = 2,
                 errorMsgDetails = "添加列->" + tableName,
                 UserId          = UserId,
             });
             return("");
         }
         else
         {
             return("该列已存在!");
         }
     }
     catch (Exception ex)
     {
         return("添加失败!");
     }
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public List <model.tableFiledPerssion> DataRowToModel(DataRowCollection rowCollection)
        {
            List <model.tableFiledPerssion> list = new List <model.tableFiledPerssion>();

            foreach (DataRow row in rowCollection)
            {
                model.tableFiledPerssion modelMd = new model.tableFiledPerssion();
                if (row != null)
                {
                    if (row["Id"] != null && row["Id"].ToString() != "")
                    {
                        modelMd.Id = int.Parse(row["Id"].ToString());
                    }
                    if (row["tableName"] != null)
                    {
                        modelMd.tableName = row["tableName"].ToString();
                    }
                    if (row["tableFiled"] != null)
                    {
                        modelMd.tableFiled = row["tableFiled"].ToString();
                    }
                    if (row["tableLevel"] != null && row["tableLevel"].ToString() != "")
                    {
                        modelMd.tableLevel = int.Parse(row["tableLevel"].ToString());
                    }
                    if (row["tableNameState"] != null && row["tableNameState"].ToString() != "")
                    {
                        modelMd.tableNameState = int.Parse(row["tableNameState"].ToString());
                    }
                    if (row["tableFiledState"] != null && row["tableFiledState"].ToString() != "")
                    {
                        modelMd.tableFiledState = int.Parse(row["tableFiledState"].ToString());
                    }
                    if (row["tableIndex"] != null && row["tableIndex"].ToString() != "")
                    {
                        modelMd.tableIndex = int.Parse(row["tableIndex"].ToString());
                    }
                    if (row["UserId"] != null && row["UserId"].ToString() != "")
                    {
                        modelMd.UserId = int.Parse(row["UserId"].ToString());
                    }
                    if (row["Def1"] != null)
                    {
                        modelMd.Def1 = row["Def1"].ToString();
                    }
                    if (row["Def2"] != null)
                    {
                        modelMd.Def2 = row["Def2"].ToString();
                    }
                    if (row["Def3"] != null)
                    {
                        modelMd.Def3 = row["Def3"].ToString();
                    }
                    if (row["Def4"] != null)
                    {
                        modelMd.Def4 = row["Def4"].ToString();
                    }
                    if (row["Def5"] != null)
                    {
                        modelMd.Def5 = row["Def5"].ToString();
                    }
                }

                list.Add(modelMd);
            }

            return(list);
        }