/// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(XHD.Model.scm_stock model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into scm_stock(");
            strSql.Append("factory_Id,suppliers_id,goods_id,goods_sn,goods_name,brand_id,cat_id,goods_unit,create_id,create_name,create_date,goods_oldname)");
            strSql.Append(" values (");
            strSql.Append("@factory_Id,@suppliers_id,@goods_id,@goods_sn,@goods_name,@brand_id,@cat_id,@goods_unit,@create_id,@create_name,@create_date,@goods_oldname)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@factory_Id",    MySqlDbType.VarChar,    60),
                new MySqlParameter("@suppliers_id",  MySqlDbType.Int16,       5),
                new MySqlParameter("@goods_id",      MySqlDbType.Int16,       8),
                new MySqlParameter("@goods_sn",      MySqlDbType.VarChar,    60),
                new MySqlParameter("@goods_name",    MySqlDbType.VarChar,   120),
                new MySqlParameter("@brand_id",      MySqlDbType.Int16,       5),
                new MySqlParameter("@cat_id",        MySqlDbType.Int16,       5),
                //new MySqlParameter("@stockQry", MySqlDbType.Int32,11),
                //new MySqlParameter("@price", MySqlDbType.Decimal,12),
                new MySqlParameter("@goods_unit",    MySqlDbType.VarChar,    20),
                new MySqlParameter("@create_id",     MySqlDbType.Int32,      11),
                new MySqlParameter("@create_name",   MySqlDbType.VarChar,   250),
                new MySqlParameter("@create_date",   MySqlDbType.DateTime),
                new MySqlParameter("@goods_oldname", MySqlDbType.VarChar, 120)
            };
            parameters[0].Value = model.factory_Id;
            parameters[1].Value = model.suppliers_id;
            parameters[2].Value = model.goods_id;
            parameters[3].Value = model.goods_sn;
            parameters[4].Value = model.goods_name;
            parameters[5].Value = model.brand_id;
            parameters[6].Value = model.cat_id;
            //parameters[7].Value = model.stockQry;
            //parameters[8].Value = model.price;
            parameters[7].Value  = model.goods_unit;
            parameters[8].Value  = model.create_id;
            parameters[9].Value  = model.create_name;
            parameters[10].Value = model.create_date;
            parameters[11].Value = model.goods_oldname;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XHD.Model.scm_stock GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Id,factory_Id,suppliers_id,goods_id,goods_sn,goods_name,brand_id,cat_id,stockQry,price,goods_unit,create_id,create_name,create_date,update_id,update_name,update_date from scm_stock ");
            strSql.Append(" where Id=@Id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@Id", MySqlDbType.Int32)
            };
            parameters[0].Value = Id;

            XHD.Model.scm_stock model = new XHD.Model.scm_stock();
            DataSet             ds    = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XHD.Model.scm_stock DataRowToModel(DataRow row)
 {
     XHD.Model.scm_stock model = new XHD.Model.scm_stock();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["factory_Id"] != null)
         {
             model.factory_Id = row["factory_Id"].ToString();
         }
         if (row["suppliers_id"] != null && row["suppliers_id"].ToString() != "")
         {
             model.suppliers_id = int.Parse(row["suppliers_id"].ToString());
         }
         //model.goods_id=row["goods_id"].ToString();
         if (row["goods_sn"] != null)
         {
             model.goods_sn = row["goods_sn"].ToString();
         }
         if (row["goods_name"] != null)
         {
             model.goods_name = row["goods_name"].ToString();
         }
         if (row["brand_id"] != null && row["brand_id"].ToString() != "")
         {
             model.brand_id = int.Parse(row["brand_id"].ToString());
         }
         if (row["cat_id"] != null && row["cat_id"].ToString() != "")
         {
             model.cat_id = int.Parse(row["cat_id"].ToString());
         }
         if (row["stockQry"] != null && row["stockQry"].ToString() != "")
         {
             model.stockQry = int.Parse(row["stockQry"].ToString());
         }
         if (row["price"] != null && row["price"].ToString() != "")
         {
             model.price = decimal.Parse(row["price"].ToString());
         }
         if (row["goods_unit"] != null)
         {
             model.goods_unit = row["goods_unit"].ToString();
         }
         if (row["create_id"] != null && row["create_id"].ToString() != "")
         {
             model.create_id = int.Parse(row["create_id"].ToString());
         }
         if (row["create_name"] != null)
         {
             model.create_name = row["create_name"].ToString();
         }
         if (row["create_date"] != null && row["create_date"].ToString() != "")
         {
             model.create_date = DateTime.Parse(row["create_date"].ToString());
         }
         if (row["update_id"] != null && row["update_id"].ToString() != "")
         {
             model.update_id = int.Parse(row["update_id"].ToString());
         }
         if (row["update_name"] != null)
         {
             model.update_name = row["update_name"].ToString();
         }
         if (row["update_date"] != null && row["update_date"].ToString() != "")
         {
             model.update_date = DateTime.Parse(row["update_date"].ToString());
         }
     }
     return(model);
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XHD.Model.scm_stock model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update scm_stock set ");
            strSql.Append("factory_Id=@factory_Id,");
            strSql.Append("suppliers_id=@suppliers_id,");
            strSql.Append("goods_id=@goods_id,");
            strSql.Append("goods_sn=@goods_sn,");
            strSql.Append("goods_name=@goods_name,");
            strSql.Append("brand_id=@brand_id,");
            strSql.Append("cat_id=@cat_id,");
            //strSql.Append("stockQry=@stockQry,");
            //strSql.Append("price=@price,");
            strSql.Append("goods_unit=@goods_unit,");
            strSql.Append("update_id=@update_id,");
            strSql.Append("update_name=@update_name,");
            strSql.Append("update_date=@update_date,");
            strSql.Append("goods_oldname=@goods_oldname");
            strSql.Append(" where suppliers_id=@suppliers_Oid");
            strSql.Append(" and goods_id=@goods_Oid");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@factory_Id",    MySqlDbType.VarChar,    60),
                new MySqlParameter("@suppliers_id",  MySqlDbType.Int16,       5),
                new MySqlParameter("@goods_id",      MySqlDbType.Int16,       8),
                new MySqlParameter("@goods_sn",      MySqlDbType.VarChar,    60),
                new MySqlParameter("@goods_name",    MySqlDbType.VarChar,   120),
                new MySqlParameter("@brand_id",      MySqlDbType.Int16,       5),
                new MySqlParameter("@cat_id",        MySqlDbType.Int16,       5),
                //new MySqlParameter("@stockQry", MySqlDbType.Int32,11),
                //new MySqlParameter("@price", MySqlDbType.Decimal,12),
                new MySqlParameter("@goods_unit",    MySqlDbType.VarChar,    20),
                new MySqlParameter("@update_id",     MySqlDbType.Int32,      11),
                new MySqlParameter("@update_name",   MySqlDbType.VarChar,   250),
                new MySqlParameter("@update_date",   MySqlDbType.DateTime),
                new MySqlParameter("@suppliers_Oid", MySqlDbType.Int16,       8),
                new MySqlParameter("@goods_Oid",     MySqlDbType.Int16,       8),
                new MySqlParameter("@goods_oldname", MySqlDbType.VarChar, 120)
            };
            parameters[0].Value = model.factory_Id;
            parameters[1].Value = model.suppliers_id;
            parameters[2].Value = model.goods_id;
            parameters[3].Value = model.goods_sn;
            parameters[4].Value = model.goods_name;
            parameters[5].Value = model.brand_id;
            parameters[6].Value = model.cat_id;
            //parameters[7].Value = model.stockQry;
            //parameters[8].Value = model.price;
            parameters[7].Value  = model.goods_unit;
            parameters[8].Value  = model.update_id;
            parameters[9].Value  = model.update_name;
            parameters[10].Value = model.update_date;
            parameters[11].Value = model.suppliers_id;
            parameters[12].Value = model.Id;
            parameters[13].Value = model.goods_oldname;

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

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