示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SchSystem.Model.ServFuncExt model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ServFuncExt(");
            strSql.Append("FuncId,NapeCode,NapeCodes,NapeC)");
            strSql.Append(" values (");
            strSql.Append("@FuncId,@NapeCode,@NapeCodes,@NapeC)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FuncId",    SqlDbType.Int,       4),
                new SqlParameter("@NapeCode",  SqlDbType.VarChar,  10),
                new SqlParameter("@NapeCodes", SqlDbType.VarChar, 200),
                new SqlParameter("@NapeC",     SqlDbType.TinyInt, 1)
            };
            parameters[0].Value = model.FuncId;
            parameters[1].Value = model.NapeCode;
            parameters[2].Value = model.NapeCodes;
            parameters[3].Value = model.NapeC;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SchSystem.Model.ServFuncExt DataRowToModel(DataRow row)
 {
     SchSystem.Model.ServFuncExt model = new SchSystem.Model.ServFuncExt();
     if (row != null)
     {
         if (row["AutoId"] != null && row["AutoId"].ToString() != "")
         {
             model.AutoId = int.Parse(row["AutoId"].ToString());
         }
         if (row["FuncId"] != null && row["FuncId"].ToString() != "")
         {
             model.FuncId = int.Parse(row["FuncId"].ToString());
         }
         if (row["NapeCode"] != null)
         {
             model.NapeCode = row["NapeCode"].ToString();
         }
         if (row["NapeCodes"] != null)
         {
             model.NapeCodes = row["NapeCodes"].ToString();
         }
         if (row["NapeC"] != null && row["NapeC"].ToString() != "")
         {
             model.NapeC = int.Parse(row["NapeC"].ToString());
         }
     }
     return(model);
 }
示例#3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SchSystem.Model.ServFuncExt model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ServFuncExt set ");
            strSql.Append("FuncId=@FuncId,");
            strSql.Append("NapeCode=@NapeCode,");
            strSql.Append("NapeCodes=@NapeCodes,");
            strSql.Append("NapeC=@NapeC");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FuncId",    SqlDbType.Int,       4),
                new SqlParameter("@NapeCode",  SqlDbType.VarChar,  10),
                new SqlParameter("@NapeCodes", SqlDbType.VarChar, 200),
                new SqlParameter("@NapeC",     SqlDbType.TinyInt,   1),
                new SqlParameter("@AutoId",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.FuncId;
            parameters[1].Value = model.NapeCode;
            parameters[2].Value = model.NapeCodes;
            parameters[3].Value = model.NapeC;
            parameters[4].Value = model.AutoId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SchSystem.Model.ServFuncExt GetModel(int AutoId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 AutoId,FuncId,NapeCode,NapeCodes,NapeC from ServFuncExt ");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AutoId", SqlDbType.Int, 4)
            };
            parameters[0].Value = AutoId;

            SchSystem.Model.ServFuncExt model = new SchSystem.Model.ServFuncExt();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
        public static Com.DataPack.DataRsp <string> FuncEditSave(List <string> arr)
        {
            Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
            string oldFuncCode = "";

            if (Com.Session.userid == null)
            {
                rsp.code = "expire";
                rsp.msg  = "你现在登录已过期,请重新登录!";
            }
            else
            {
                try
                {
                    SchSystem.BLL.ServFunc   sfcBll   = new SchSystem.BLL.ServFunc();
                    SchSystem.Model.ServFunc sfcModel = new SchSystem.Model.ServFunc();
                    foreach (string str in arr)
                    {
                        string[] strarr = str.Split('#');
                        if (strarr[0] == "autoid")
                        {
                            sfcModel.AutoId = int.Parse(strarr[1]);
                        }
                        else if (strarr[0] == "businesstype")
                        {
                            sfcModel.TypeCode = strarr[1].Trim();
                        }
                        else if (strarr[0] == "businesscode")
                        {
                            sfcModel.FuncCode = strarr[1].Trim();
                        }
                        else if (strarr[0] == "oldbusinesscode")
                        {
                            oldFuncCode = strarr[1].Trim();
                        }
                        else if (strarr[0] == "funcname")
                        {
                            sfcModel.FuncName = strarr[1].Trim();
                        }
                        else if (strarr[0] == "userange")
                        {
                            sfcModel.FuncRange = strarr[1].Trim();
                        }
                        else if (strarr[0] == "addsetinfo")
                        {
                            sfcModel.FuncSet = strarr[1].Trim();
                        }
                        else if (strarr[0] == "businessdesc")
                        {
                            sfcModel.FuncDes = strarr[1].Trim();
                        }
                        else if (strarr[0] == "tagsbusplatfrom")
                        {
                            sfcModel.FuncSyss = strarr[1].Trim();
                        }
                        else if (strarr[0] == "note")
                        {
                            sfcModel.FuncNote = strarr[1].Trim();
                        }
                    }
                    if (sfcModel.TypeCode == "" || sfcModel.FuncCode == "" || sfcModel.FuncName == "" || sfcModel.FuncRange == "" || sfcModel.FuncSet == "" || sfcModel.FuncSyss == "")
                    {
                        rsp.code = "error";
                        rsp.msg  = "操作失败!不允许输入空格";
                    }
                    else
                    {
                        bool resbool = false;
                        if (sfcModel.FuncCode != oldFuncCode)
                        {
                            resbool = sfcBll.Exists(sfcModel.FuncCode);
                        }
                        if (resbool == false)
                        {
                            bool result = sfcBll.Update(sfcModel);
                            if (result)
                            {
                                SchSystem.BLL.ServFuncExt   sfeBll   = new SchSystem.BLL.ServFuncExt();
                                SchSystem.Model.ServFuncExt sfeModel = new SchSystem.Model.ServFuncExt();
                                sfeBll.Delete(sfcModel.AutoId);
                                string   FuncSet       = sfcModel.FuncSet;
                                string[] FuncSetRecArr = FuncSet.Split('|');//英文半角“|”
                                for (int i = 0; i < FuncSetRecArr.Length; i++)
                                {
                                    string[] FuncSetItemArr = FuncSetRecArr[i].Split('!');//英文半角“!”
                                    sfeModel.FuncId    = sfcModel.AutoId;
                                    sfeModel.NapeCode  = FuncSetItemArr[0];
                                    sfeModel.NapeCodes = FuncSetItemArr[1];
                                    sfeModel.NapeC     = int.Parse(FuncSetItemArr[2]);
                                    sfeBll.Add(sfeModel);
                                }
                                rsp.code = "success";
                                rsp.msg  = "操作成功";
                            }
                            else
                            {
                                rsp.code = "error";
                                rsp.msg  = "操作失败";
                            }
                        }
                        else
                        {
                            rsp.code = "codeRepeat";
                            rsp.msg  = "功能代码不允许重复";
                        }
                    }
                }
                catch (Exception ex)
                {
                    rsp.code = "excepError";
                    rsp.msg  = ex.Message;
                }
            }
            return(rsp);
        }