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

            strSql.Append("insert into Info_staff(");
            strSql.Append("staffNum,staffName,staffAvatar,staffSex,staffAge,staffMobile,staffPassword,ProvinceID,ProvinceName,CityID,CityName,DistrictID,DistrictName,Address,IsDelete)");
            strSql.Append(" values (");
            strSql.Append("SQL2012staffNum,SQL2012staffName,SQL2012staffAvatar,SQL2012staffSex,SQL2012staffAge,SQL2012staffMobile,SQL2012staffPassword,SQL2012ProvinceID,SQL2012ProvinceName,SQL2012CityID,SQL2012CityName,SQL2012DistrictID,SQL2012DistrictName,SQL2012Address,SQL2012IsDelete)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012staffNum",      SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012staffName",     SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012staffAvatar",   SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012staffSex",      SqlDbType.Int,      4),
                new SqlParameter("SQL2012staffAge",      SqlDbType.Int,      4),
                new SqlParameter("SQL2012staffMobile",   SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012staffPassword", SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012ProvinceID",    SqlDbType.Int,      4),
                new SqlParameter("SQL2012ProvinceName",  SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012CityID",        SqlDbType.Int,      4),
                new SqlParameter("SQL2012CityName",      SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012DistrictID",    SqlDbType.Int,      4),
                new SqlParameter("SQL2012DistrictName",  SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012Address",       SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012IsDelete",      SqlDbType.Bit, 1)
            };
            parameters[0].Value  = model.staffNum;
            parameters[1].Value  = model.staffName;
            parameters[2].Value  = model.staffAvatar;
            parameters[3].Value  = model.staffSex;
            parameters[4].Value  = model.staffAge;
            parameters[5].Value  = model.staffMobile;
            parameters[6].Value  = model.staffPassword;
            parameters[7].Value  = model.ProvinceID;
            parameters[8].Value  = model.ProvinceName;
            parameters[9].Value  = model.CityID;
            parameters[10].Value = model.CityName;
            parameters[11].Value = model.DistrictID;
            parameters[12].Value = model.DistrictName;
            parameters[13].Value = model.Address;
            parameters[14].Value = model.IsDelete;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Info_staffModel GetModel(int staffID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 staffNum,staffName,staffAvatar,staffSex,staffAge,staffMobile,staffPassword,ProvinceID,ProvinceName,CityID,CityName,DistrictID,DistrictName,Address,IsDelete from Info_staff ");
            strSql.Append(" where staffID=SQL2012staffID");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012staffID", SqlDbType.Int, 4)
            };
            parameters[0].Value = staffID;

            Info_staffModel model = new Info_staffModel();
            DataSet         ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Info_staffModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Info_staff set ");
            strSql.Append("staffNum=SQL2012staffNum,");
            strSql.Append("staffName=SQL2012staffName,");
            strSql.Append("staffAvatar=SQL2012staffAvatar,");
            strSql.Append("staffSex=SQL2012staffSex,");
            strSql.Append("staffAge=SQL2012staffAge,");
            strSql.Append("staffMobile=SQL2012staffMobile,");
            strSql.Append("staffPassword=SQL2012staffPassword,");
            strSql.Append("ProvinceID=SQL2012ProvinceID,");
            strSql.Append("ProvinceName=SQL2012ProvinceName,");
            strSql.Append("CityID=SQL2012CityID,");
            strSql.Append("CityName=SQL2012CityName,");
            strSql.Append("DistrictID=SQL2012DistrictID,");
            strSql.Append("DistrictName=SQL2012DistrictName,");
            strSql.Append("Address=SQL2012Address,");
            strSql.Append("IsDelete=SQL2012IsDelete");
            strSql.Append(" where staffID=SQL2012staffID");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012staffNum",      SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012staffName",     SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012staffAvatar",   SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012staffSex",      SqlDbType.Int,      4),
                new SqlParameter("SQL2012staffAge",      SqlDbType.Int,      4),
                new SqlParameter("SQL2012staffMobile",   SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012staffPassword", SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012ProvinceID",    SqlDbType.Int,      4),
                new SqlParameter("SQL2012ProvinceName",  SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012CityID",        SqlDbType.Int,      4),
                new SqlParameter("SQL2012CityName",      SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012DistrictID",    SqlDbType.Int,      4),
                new SqlParameter("SQL2012DistrictName",  SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012Address",       SqlDbType.VarChar, 50),
                new SqlParameter("SQL2012IsDelete",      SqlDbType.Bit, 1)
            };
            parameters[0].Value  = model.staffNum;
            parameters[1].Value  = model.staffName;
            parameters[2].Value  = model.staffAvatar;
            parameters[3].Value  = model.staffSex;
            parameters[4].Value  = model.staffAge;
            parameters[5].Value  = model.staffMobile;
            parameters[6].Value  = model.staffPassword;
            parameters[7].Value  = model.ProvinceID;
            parameters[8].Value  = model.ProvinceName;
            parameters[9].Value  = model.CityID;
            parameters[10].Value = model.CityName;
            parameters[11].Value = model.DistrictID;
            parameters[12].Value = model.DistrictName;
            parameters[13].Value = model.Address;
            parameters[14].Value = model.IsDelete;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Info_staffModel DataRowToModel(DataRow row)
        {
            Info_staffModel model = new Info_staffModel();

            if (row != null)
            {
                if (row["staffNum"] != null)
                {
                    model.staffNum = row["staffNum"].ToString();
                }
                if (row["staffName"] != null)
                {
                    model.staffName = row["staffName"].ToString();
                }
                if (row["staffAvatar"] != null)
                {
                    model.staffAvatar = row["staffAvatar"].ToString();
                }
                if (row["staffSex"] != null && row["staffSex"].ToString() != "")
                {
                    model.staffSex = int.Parse(row["staffSex"].ToString());
                }
                if (row["staffAge"] != null && row["staffAge"].ToString() != "")
                {
                    model.staffAge = int.Parse(row["staffAge"].ToString());
                }
                if (row["staffMobile"] != null)
                {
                    model.staffMobile = row["staffMobile"].ToString();
                }
                if (row["staffPassword"] != null)
                {
                    model.staffPassword = row["staffPassword"].ToString();
                }
                if (row["ProvinceID"] != null && row["ProvinceID"].ToString() != "")
                {
                    model.ProvinceID = int.Parse(row["ProvinceID"].ToString());
                }
                if (row["ProvinceName"] != null)
                {
                    model.ProvinceName = row["ProvinceName"].ToString();
                }
                if (row["CityID"] != null && row["CityID"].ToString() != "")
                {
                    model.CityID = int.Parse(row["CityID"].ToString());
                }
                if (row["CityName"] != null)
                {
                    model.CityName = row["CityName"].ToString();
                }
                if (row["DistrictID"] != null && row["DistrictID"].ToString() != "")
                {
                    model.DistrictID = int.Parse(row["DistrictID"].ToString());
                }
                if (row["DistrictName"] != null)
                {
                    model.DistrictName = row["DistrictName"].ToString();
                }
                if (row["Address"] != null)
                {
                    model.Address = row["Address"].ToString();
                }
                if (row["IsDelete"] != null && row["IsDelete"].ToString() != "")
                {
                    if ((row["IsDelete"].ToString() == "1") || (row["IsDelete"].ToString().ToLower() == "true"))
                    {
                        model.IsDelete = true;
                    }
                    else
                    {
                        model.IsDelete = false;
                    }
                }
            }
            return(model);
        }
示例#5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Info_staffModel model)
 {
     return(dal.Update(model));
 }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Info_staffModel model)
 {
     return(dal.Add(model));
 }