Exemple #1
0
 /// <summary>
 /// 由一行数据得到一个实体
 /// </summary>
 private Hi.Model.BD_SalesMan GetModel(DataRow r)
 {
     Hi.Model.BD_SalesMan model = new Hi.Model.BD_SalesMan();
     model.ID         = SqlHelper.GetInt(r["ID"]);
     model.OrgID      = SqlHelper.GetInt(r["OrgID"]);
     model.SalesName  = SqlHelper.GetString(r["SalesName"]);
     model.SalesCode  = SqlHelper.GetString(r["SalesCode"]);
     model.Phone      = SqlHelper.GetString(r["Phone"]);
     model.Email      = SqlHelper.GetString(r["Email"]);
     model.Remark     = SqlHelper.GetString(r["Remark"]);
     model.IsEnabled  = SqlHelper.GetInt(r["IsEnabled"]);
     model.ts         = SqlHelper.GetDateTime(r["ts"]);
     model.dr         = SqlHelper.GetInt(r["dr"]);
     model.modifyuser = SqlHelper.GetInt(r["modifyuser"]);
     return(model);
 }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hi.Model.BD_SalesMan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [BD_SalesMan](");
            strSql.Append("[OrgID],[SalesName],[SalesCode],[Phone],[Email],[Remark],[IsEnabled],[ts],[modifyuser])");
            strSql.Append(" values (");
            strSql.Append("@OrgID,@SalesName,@SalesCode,@Phone,@Email,@Remark,@IsEnabled,@ts,@modifyuser)");
            strSql.Append(";select @@Identity");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrgID",      SqlDbType.Int),
                new SqlParameter("@SalesName",  SqlDbType.VarChar,    50),
                new SqlParameter("@SalesCode",  SqlDbType.VarChar,    50),
                new SqlParameter("@Phone",      SqlDbType.VarChar,    50),
                new SqlParameter("@Email",      SqlDbType.VarChar,    50),
                new SqlParameter("@Remark",     SqlDbType.VarChar,   500),
                new SqlParameter("@IsEnabled",  SqlDbType.Int),
                new SqlParameter("@ts",         SqlDbType.DateTime),
                new SqlParameter("@modifyuser", SqlDbType.Int)
            };
            parameters[0].Value = model.OrgID;

            if (model.SalesName != null)
            {
                parameters[1].Value = model.SalesName;
            }
            else
            {
                parameters[1].Value = DBNull.Value;
            }


            if (model.SalesCode != null)
            {
                parameters[2].Value = model.SalesCode;
            }
            else
            {
                parameters[2].Value = DBNull.Value;
            }


            if (model.Phone != null)
            {
                parameters[3].Value = model.Phone;
            }
            else
            {
                parameters[3].Value = DBNull.Value;
            }


            if (model.Email != null)
            {
                parameters[4].Value = model.Email;
            }
            else
            {
                parameters[4].Value = DBNull.Value;
            }


            if (model.Remark != null)
            {
                parameters[5].Value = model.Remark;
            }
            else
            {
                parameters[5].Value = DBNull.Value;
            }

            parameters[6].Value = model.IsEnabled;
            parameters[7].Value = model.ts;
            parameters[8].Value = model.modifyuser;
            return(SqlHelper.GetInt(SqlHelper.GetSingle(SqlHelper.LocalSqlServer, strSql.ToString(), parameters)));
        }
Exemple #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hi.Model.BD_SalesMan model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [BD_SalesMan] set ");
            strSql.Append("[OrgID]=@OrgID,");
            strSql.Append("[SalesName]=@SalesName,");
            strSql.Append("[SalesCode]=@SalesCode,");
            strSql.Append("[Phone]=@Phone,");
            strSql.Append("[Email]=@Email,");
            strSql.Append("[Remark]=@Remark,");
            strSql.Append("[IsEnabled]=@IsEnabled,");
            strSql.Append("[ts]=@ts,");
            strSql.Append("[dr]=@dr,");
            strSql.Append("[modifyuser]=@modifyuser");
            strSql.Append(" where [ID]=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",         SqlDbType.Int),
                new SqlParameter("@OrgID",      SqlDbType.Int),
                new SqlParameter("@SalesName",  SqlDbType.VarChar,    50),
                new SqlParameter("@SalesCode",  SqlDbType.VarChar,    50),
                new SqlParameter("@Phone",      SqlDbType.VarChar,    50),
                new SqlParameter("@Email",      SqlDbType.VarChar,    50),
                new SqlParameter("@Remark",     SqlDbType.VarChar,   500),
                new SqlParameter("@IsEnabled",  SqlDbType.Int),
                new SqlParameter("@ts",         SqlDbType.DateTime),
                new SqlParameter("@dr",         SqlDbType.SmallInt),
                new SqlParameter("@modifyuser", SqlDbType.Int)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.OrgID;

            if (model.SalesName != null)
            {
                parameters[2].Value = model.SalesName;
            }
            else
            {
                parameters[2].Value = DBNull.Value;
            }


            if (model.SalesCode != null)
            {
                parameters[3].Value = model.SalesCode;
            }
            else
            {
                parameters[3].Value = DBNull.Value;
            }


            if (model.Phone != null)
            {
                parameters[4].Value = model.Phone;
            }
            else
            {
                parameters[4].Value = DBNull.Value;
            }


            if (model.Email != null)
            {
                parameters[5].Value = model.Email;
            }
            else
            {
                parameters[5].Value = DBNull.Value;
            }


            if (model.Remark != null)
            {
                parameters[6].Value = model.Remark;
            }
            else
            {
                parameters[6].Value = DBNull.Value;
            }

            parameters[7].Value  = model.IsEnabled;
            parameters[8].Value  = model.ts;
            parameters[9].Value  = model.dr;
            parameters[10].Value = model.modifyuser;

            return(SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString(), parameters) > 0);
        }