Example #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WMS_Database.Goods_SupplierModel DataRowToModel(DataRow row)
 {
     WMS_Database.Goods_SupplierModel model = new WMS_Database.Goods_SupplierModel();
     if (row != null)
     {
         if (row["Goods_Supplier_ID"] != null)
         {
             model.Goods_Supplier_ID = row["Goods_Supplier_ID"].ToString();
         }
         if (row["Goods_Supplier_Name"] != null)
         {
             model.Goods_Supplier_Name = row["Goods_Supplier_Name"].ToString();
         }
         if (row["Goods_Supplier_Code"] != null)
         {
             model.Goods_Supplier_Code = row["Goods_Supplier_Code"].ToString();
         }
         if (row["Goods_Supplier_Telephone"] != null)
         {
             model.Goods_Supplier_Telephone = row["Goods_Supplier_Telephone"].ToString();
         }
         if (row["Goods_Supplier_Addr"] != null)
         {
             model.Goods_Supplier_Addr = row["Goods_Supplier_Addr"].ToString();
         }
         if (row["Goods_Supplier_Remark"] != null)
         {
             model.Goods_Supplier_Remark = row["Goods_Supplier_Remark"].ToString();
         }
     }
     return(model);
 }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WMS_Database.Goods_SupplierModel model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.Goods_Supplier_ID != null)
            {
                strSql1.Append("Goods_Supplier_ID,");
                strSql2.Append("'" + model.Goods_Supplier_ID + "',");
            }
            if (model.Goods_Supplier_Name != null)
            {
                strSql1.Append("Goods_Supplier_Name,");
                strSql2.Append("'" + model.Goods_Supplier_Name + "',");
            }
            if (model.Goods_Supplier_Code != null)
            {
                strSql1.Append("Goods_Supplier_Code,");
                strSql2.Append("'" + model.Goods_Supplier_Code + "',");
            }
            if (model.Goods_Supplier_Telephone != null)
            {
                strSql1.Append("Goods_Supplier_Telephone,");
                strSql2.Append("'" + model.Goods_Supplier_Telephone + "',");
            }
            if (model.Goods_Supplier_Addr != null)
            {
                strSql1.Append("Goods_Supplier_Addr,");
                strSql2.Append("'" + model.Goods_Supplier_Addr + "',");
            }
            if (model.Goods_Supplier_Remark != null)
            {
                strSql1.Append("Goods_Supplier_Remark,");
                strSql2.Append("'" + model.Goods_Supplier_Remark + "',");
            }
            strSql.Append("insert into Goods_Supplier(");
            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);
            }
        }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WMS_Database.Goods_SupplierModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Goods_Supplier set ");
            if (model.Goods_Supplier_Name != null)
            {
                strSql.Append("Goods_Supplier_Name='" + model.Goods_Supplier_Name + "',");
            }
            if (model.Goods_Supplier_Code != null)
            {
                strSql.Append("Goods_Supplier_Code='" + model.Goods_Supplier_Code + "',");
            }
            if (model.Goods_Supplier_Telephone != null)
            {
                strSql.Append("Goods_Supplier_Telephone='" + model.Goods_Supplier_Telephone + "',");
            }
            else
            {
                strSql.Append("Goods_Supplier_Telephone= null ,");
            }
            if (model.Goods_Supplier_Addr != null)
            {
                strSql.Append("Goods_Supplier_Addr='" + model.Goods_Supplier_Addr + "',");
            }
            else
            {
                strSql.Append("Goods_Supplier_Addr= null ,");
            }
            if (model.Goods_Supplier_Remark != null)
            {
                strSql.Append("Goods_Supplier_Remark='" + model.Goods_Supplier_Remark + "',");
            }
            else
            {
                strSql.Append("Goods_Supplier_Remark= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

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

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WMS_Database.Goods_SupplierModel GetModel(string Goods_Supplier_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" Goods_Supplier_ID,Goods_Supplier_Name,Goods_Supplier_Code,Goods_Supplier_Telephone,Goods_Supplier_Addr,Goods_Supplier_Remark ");
            strSql.Append(" from Goods_Supplier ");
            strSql.Append(" where Goods_Supplier_ID='" + Goods_Supplier_ID + "' ");
            WMS_Database.Goods_SupplierModel model = new WMS_Database.Goods_SupplierModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

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