Example #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtSupplier_ID.Text))
            {
                strErr += "Supplier_ID格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int Product_ID  = int.Parse(this.lblProduct_ID.Text);
            int Supplier_ID = int.Parse(this.txtSupplier_ID.Text);


            ZhangWei.Model.Product_Supplier model = new ZhangWei.Model.Product_Supplier();
            model.Product_ID  = Product_ID;
            model.Supplier_ID = Supplier_ID;

            ZhangWei.BLL.Product_Supplier bll = new ZhangWei.BLL.Product_Supplier();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Example #2
0
 private void ShowInfo(int Product_ID)
 {
     ZhangWei.BLL.Product_Supplier   bll   = new ZhangWei.BLL.Product_Supplier();
     ZhangWei.Model.Product_Supplier model = bll.GetModel(Product_ID);
     this.lblProduct_ID.Text  = model.Product_ID.ToString();
     this.txtSupplier_ID.Text = model.Supplier_ID.ToString();
 }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ZhangWei.Model.Product_Supplier model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Product_Supplier(");
            strSql.Append("Product_ID,Supplier_ID)");
            strSql.Append(" values (");
            strSql.Append("@Product_ID,@Supplier_ID)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Product_ID",  SqlDbType.Int, 4),
                new SqlParameter("@Supplier_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Product_ID;
            parameters[1].Value = model.Supplier_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ZhangWei.Model.Product_Supplier model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Product_Supplier set ");
            strSql.Append("Supplier_ID=@Supplier_ID");
            strSql.Append(" where Product_ID=@Product_ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Supplier_ID", SqlDbType.Int, 4),
                new SqlParameter("@Product_ID",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Supplier_ID;
            parameters[1].Value = model.Product_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZhangWei.Model.Product_Supplier GetModel(int Product_ID)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Product_ID"] != null && ds.Tables[0].Rows[0]["Product_ID"].ToString() != "")
                {
                    model.Product_ID = int.Parse(ds.Tables[0].Rows[0]["Product_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Supplier_ID"] != null && ds.Tables[0].Rows[0]["Supplier_ID"].ToString() != "")
                {
                    model.Supplier_ID = int.Parse(ds.Tables[0].Rows[0]["Supplier_ID"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }