Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.Charge model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.cusID != null)
            {
                strSql1.Append("cusID,");
                strSql2.Append("'" + model.cusID + "',");
            }
            if (model.manID != null)
            {
                strSql1.Append("manID,");
                strSql2.Append("'" + model.manID + "',");
            }
            strSql.Append("insert into Charge(");
            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);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Charge DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Charge model = new Maticsoft.Model.Charge();
     if (row != null)
     {
         if (row["cusID"] != null)
         {
             model.cusID = row["cusID"].ToString();
         }
         if (row["manID"] != null)
         {
             model.manID = row["manID"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.Charge model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Charge set ");
            int n = strSql.ToString().LastIndexOf(",");

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

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Charge GetModel(string cusID, string manID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" cusID,manID ");
            strSql.Append(" from Charge ");
            strSql.Append(" where cusID='" + cusID + "' and manID='" + manID + "' ");
            Maticsoft.Model.Charge model = new Maticsoft.Model.Charge();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

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