Beispiel #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XCWeiXin.Model.wx_diancai_dianyuan DataRowToModel(DataRow row)
 {
     XCWeiXin.Model.wx_diancai_dianyuan model = new XCWeiXin.Model.wx_diancai_dianyuan();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["shopid"] != null && row["shopid"].ToString() != "")
         {
             model.shopid = int.Parse(row["shopid"].ToString());
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
         if (row["bianhao"] != null)
         {
             model.bianhao = row["bianhao"].ToString();
         }
         if (row["dianyuanName"] != null)
         {
             model.dianyuanName = row["dianyuanName"].ToString();
         }
         if (row["dianyuanTel"] != null)
         {
             model.dianyuanTel = row["dianyuanTel"].ToString();
         }
         if (row["userName"] != null)
         {
             model.userName = row["userName"].ToString();
         }
         if (row["pwd"] != null)
         {
             model.pwd = row["pwd"].ToString();
         }
         if (row["userStatus"] != null && row["userStatus"].ToString() != "")
         {
             model.userStatus = int.Parse(row["userStatus"].ToString());
         }
         if (row["fendian"] != null)
         {
             model.fendian = row["fendian"].ToString();
         }
         if (row["beginTime"] != null && row["beginTime"].ToString() != "")
         {
             model.beginTime = DateTime.Parse(row["beginTime"].ToString());
         }
         if (row["endTime"] != null && row["endTime"].ToString() != "")
         {
             model.endTime = DateTime.Parse(row["endTime"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
     }
     return(model);
 }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XCWeiXin.Model.wx_diancai_dianyuan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_diancai_dianyuan set ");
            strSql.Append("shopid=@shopid,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("bianhao=@bianhao,");
            strSql.Append("dianyuanName=@dianyuanName,");
            strSql.Append("dianyuanTel=@dianyuanTel,");
            strSql.Append("userName=@userName,");
            strSql.Append("pwd=@pwd,");
            strSql.Append("userStatus=@userStatus,");
            strSql.Append("fendian=@fendian,");
            strSql.Append("beginTime=@beginTime,");
            strSql.Append("endTime=@endTime,");
            strSql.Append("remark=@remark");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shopid",       SqlDbType.Int,         4),
                new SqlParameter("@createDate",   SqlDbType.DateTime),
                new SqlParameter("@bianhao",      SqlDbType.VarChar,   100),
                new SqlParameter("@dianyuanName", SqlDbType.VarChar,   100),
                new SqlParameter("@dianyuanTel",  SqlDbType.VarChar,   100),
                new SqlParameter("@userName",     SqlDbType.VarChar,   100),
                new SqlParameter("@pwd",          SqlDbType.VarChar,   100),
                new SqlParameter("@userStatus",   SqlDbType.Int,         4),
                new SqlParameter("@fendian",      SqlDbType.VarChar,   100),
                new SqlParameter("@beginTime",    SqlDbType.DateTime),
                new SqlParameter("@endTime",      SqlDbType.DateTime),
                new SqlParameter("@remark",       SqlDbType.NVarChar,  100),
                new SqlParameter("@id",           SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.shopid;
            parameters[1].Value  = model.createDate;
            parameters[2].Value  = model.bianhao;
            parameters[3].Value  = model.dianyuanName;
            parameters[4].Value  = model.dianyuanTel;
            parameters[5].Value  = model.userName;
            parameters[6].Value  = model.pwd;
            parameters[7].Value  = model.userStatus;
            parameters[8].Value  = model.fendian;
            parameters[9].Value  = model.beginTime;
            parameters[10].Value = model.endTime;
            parameters[11].Value = model.remark;
            parameters[12].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(XCWeiXin.Model.wx_diancai_dianyuan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_diancai_dianyuan(");
            strSql.Append("shopid,createDate,bianhao,dianyuanName,dianyuanTel,userName,pwd,userStatus,fendian,beginTime,endTime,remark)");
            strSql.Append(" values (");
            strSql.Append("@shopid,@createDate,@bianhao,@dianyuanName,@dianyuanTel,@userName,@pwd,@userStatus,@fendian,@beginTime,@endTime,@remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@shopid",       SqlDbType.Int,         4),
                new SqlParameter("@createDate",   SqlDbType.DateTime),
                new SqlParameter("@bianhao",      SqlDbType.VarChar,   100),
                new SqlParameter("@dianyuanName", SqlDbType.VarChar,   100),
                new SqlParameter("@dianyuanTel",  SqlDbType.VarChar,   100),
                new SqlParameter("@userName",     SqlDbType.VarChar,   100),
                new SqlParameter("@pwd",          SqlDbType.VarChar,   100),
                new SqlParameter("@userStatus",   SqlDbType.Int,         4),
                new SqlParameter("@fendian",      SqlDbType.VarChar,   100),
                new SqlParameter("@beginTime",    SqlDbType.DateTime),
                new SqlParameter("@endTime",      SqlDbType.DateTime),
                new SqlParameter("@remark",       SqlDbType.NVarChar, 100)
            };
            parameters[0].Value  = model.shopid;
            parameters[1].Value  = model.createDate;
            parameters[2].Value  = model.bianhao;
            parameters[3].Value  = model.dianyuanName;
            parameters[4].Value  = model.dianyuanTel;
            parameters[5].Value  = model.userName;
            parameters[6].Value  = model.pwd;
            parameters[7].Value  = model.userStatus;
            parameters[8].Value  = model.fendian;
            parameters[9].Value  = model.beginTime;
            parameters[10].Value = model.endTime;
            parameters[11].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 XCWeiXin.Model.wx_diancai_dianyuan GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,shopid,createDate,bianhao,dianyuanName,dianyuanTel,userName,pwd,userStatus,fendian,beginTime,endTime,remark from wx_diancai_dianyuan ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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