Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TSM.Model.pms_Product_Mater GetModel(int ProductMaterID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ProductMaterID,ProductMater from pms_Product_Mater ");
            strSql.Append(" where ProductMaterID=@ProductMaterID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductMaterID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ProductMaterID;

            TSM.Model.pms_Product_Mater model = new TSM.Model.pms_Product_Mater();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ProductMaterID"].ToString() != "")
                {
                    model.ProductMaterID = int.Parse(ds.Tables[0].Rows[0]["ProductMaterID"].ToString());
                }
                model.ProductMater = ds.Tables[0].Rows[0]["ProductMater"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TSM.Model.pms_Product_Mater model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into pms_Product_Mater(");
            strSql.Append("ProductMater)");
            strSql.Append(" values (");
            strSql.Append("@ProductMater)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductMater", SqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.ProductMater;

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TSM.Model.pms_Product_Mater model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update pms_Product_Mater set ");
            strSql.Append("ProductMater=@ProductMater");
            strSql.Append(" where ProductMaterID=@ProductMaterID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductMaterID", SqlDbType.Int,     4),
                new SqlParameter("@ProductMater",   SqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.ProductMaterID;
            parameters[1].Value = model.ProductMater;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Exemplo n.º 4
0
 private void SaveProductType()
 {
     TSM.Model.pms_Product_Mater modelpms_Product_Mater = new TSM.Model.pms_Product_Mater();
     modelpms_Product_Mater.ProductMater = tbxName.Text.Trim();
     m_bllpms_Product_Mater.Add(modelpms_Product_Mater);
 }