Esempio n. 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Manager DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Manager model = new Maticsoft.Model.Manager();
     if (row != null)
     {
         if (row["manID"] != null)
         {
             model.manID = row["manID"].ToString();
         }
         if (row["manName"] != null)
         {
             model.manName = row["manName"].ToString();
         }
         if (row["manSex"] != null)
         {
             model.manSex = row["manSex"].ToString();
         }
         if (row["manAge"] != null && row["manAge"].ToString() != "")
         {
             model.manAge = int.Parse(row["manAge"].ToString());
         }
         if (row["passwd"] != null)
         {
             model.passwd = row["passwd"].ToString();
         }
         if (row["manPhoto"] != null && row["manPhoto"].ToString() != "")
         {
             model.manPhoto = (byte[])row["manPhoto"];
         }
     }
     return(model);
 }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.Manager model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.manID != null)
            {
                strSql1.Append("manID,");
                strSql2.Append("'" + model.manID + "',");
            }
            if (model.manName != null)
            {
                strSql1.Append("manName,");
                strSql2.Append("'" + model.manName + "',");
            }
            if (model.manSex != null)
            {
                strSql1.Append("manSex,");
                strSql2.Append("'" + model.manSex + "',");
            }
            if (18 <= model.manAge && model.manAge <= 60)
            {
                strSql1.Append("manAge,");
                strSql2.Append("" + model.manAge + ",");
            }
            if (model.passwd != null)
            {
                strSql1.Append("passwd,");
                strSql2.Append("'" + model.passwd + "',");
            }
            if (model.manPhoto != null)
            {
                strSql1.Append("manPhoto,");
                strSql2.Append("'" + model.manPhoto + "',");
            }
            strSql.Append("insert into Manager(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        public Maticsoft.Model.Manager GetModel1(string str1)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" manID,manName,manSex,manAge,passwd,manPhoto ");
            strSql.Append(" from Manager ");
            strSql.Append(" where " + str1 + " ");
            Maticsoft.Model.Manager model = new Maticsoft.Model.Manager();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.Manager model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Manager set ");
            if (model.manName != "")
            {
                strSql.Append("manName='" + model.manName + "',");
            }
            if (model.manSex != "")
            {
                strSql.Append("manSex='" + model.manSex + "',");
            }
            if (18 <= model.manAge && model.manAge <= 60)
            {
                strSql.Append("manAge=" + model.manAge + ",");
            }
            if (model.passwd != null)
            {
                strSql.Append("passwd='" + model.passwd + "',");
            }
            if (model.manPhoto != null && model.manPhoto.Length > 0)
            {
                strSql.Append("manPhoto='" + model.manPhoto + "',");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where manID='" + model.manID + "' ");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }