Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CJH.Model.Job_HHTCode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Job_HHTCode set ");
            strSql.Append("Area_Code=@Area_Code,");
            strSql.Append("Job_Code=@Job_Code,");
            strSql.Append("Password=@Password,");
            strSql.Append("IsChild=@IsChild,");
            strSql.Append("IsCommon=@IsCommon,");
            strSql.Append("Comm_Code=@Comm_Code,");
            strSql.Append("Comm_PWD=@Comm_PWD,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Area_Code", SqlDbType.NVarChar,  6),
                new SqlParameter("@Job_Code",  SqlDbType.NVarChar, 20),
                new SqlParameter("@Password",  SqlDbType.NVarChar, 20),
                new SqlParameter("@IsChild",   SqlDbType.Int,       4),
                new SqlParameter("@IsCommon",  SqlDbType.Int,       4),
                new SqlParameter("@Comm_Code", SqlDbType.NVarChar, 20),
                new SqlParameter("@Comm_PWD",  SqlDbType.NVarChar, 20),
                new SqlParameter("@Remark",    SqlDbType.NVarChar, 50),
                new SqlParameter("@ID",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Area_Code;
            parameters[1].Value = model.Job_Code;
            parameters[2].Value = model.Password;
            parameters[3].Value = model.IsChild;
            parameters[4].Value = model.IsCommon;
            parameters[5].Value = model.Comm_Code;
            parameters[6].Value = model.Comm_PWD;
            parameters[7].Value = model.Remark;
            parameters[8].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CJH.Model.Job_HHTCode DataRowToModel(DataRow row)
 {
     CJH.Model.Job_HHTCode model = new CJH.Model.Job_HHTCode();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["Area_Code"] != null)
         {
             model.Area_Code = row["Area_Code"].ToString();
         }
         if (row["Job_Code"] != null)
         {
             model.Job_Code = row["Job_Code"].ToString();
         }
         if (row["Password"] != null)
         {
             model.Password = row["Password"].ToString();
         }
         if (row["IsChild"] != null && row["IsChild"].ToString() != "")
         {
             model.IsChild = int.Parse(row["IsChild"].ToString());
         }
         if (row["IsCommon"] != null && row["IsCommon"].ToString() != "")
         {
             model.IsCommon = int.Parse(row["IsCommon"].ToString());
         }
         if (row["Comm_Code"] != null)
         {
             model.Comm_Code = row["Comm_Code"].ToString();
         }
         if (row["Comm_PWD"] != null)
         {
             model.Comm_PWD = row["Comm_PWD"].ToString();
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
     }
     return(model);
 }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(CJH.Model.Job_HHTCode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Job_HHTCode(");
            strSql.Append("Area_Code,Job_Code,Password,IsChild,IsCommon,Comm_Code,Comm_PWD,Remark)");
            strSql.Append(" values (");
            strSql.Append("@Area_Code,@Job_Code,@Password,@IsChild,@IsCommon,@Comm_Code,@Comm_PWD,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Area_Code", SqlDbType.NVarChar,  6),
                new SqlParameter("@Job_Code",  SqlDbType.NVarChar, 20),
                new SqlParameter("@Password",  SqlDbType.NVarChar, 20),
                new SqlParameter("@IsChild",   SqlDbType.Int,       4),
                new SqlParameter("@IsCommon",  SqlDbType.Int,       4),
                new SqlParameter("@Comm_Code", SqlDbType.NVarChar, 20),
                new SqlParameter("@Comm_PWD",  SqlDbType.NVarChar, 20),
                new SqlParameter("@Remark",    SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Area_Code;
            parameters[1].Value = model.Job_Code;
            parameters[2].Value = model.Password;
            parameters[3].Value = model.IsChild;
            parameters[4].Value = model.IsCommon;
            parameters[5].Value = model.Comm_Code;
            parameters[6].Value = model.Comm_PWD;
            parameters[7].Value = model.Remark;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CJH.Model.Job_HHTCode GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,Area_Code,Job_Code,Password,IsChild,IsCommon,Comm_Code,Comm_PWD,Remark from Job_HHTCode ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }