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

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

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

            ZhangWei.Model.Dept_Supplier model = new ZhangWei.Model.Dept_Supplier();
            model.Dept_ID     = Dept_ID;
            model.Supplier_ID = Supplier_ID;

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

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

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

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

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

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZhangWei.Model.Dept_Supplier GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Dept_ID,Supplier_ID from Dept_Supplier ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Dept_ID"] != null && ds.Tables[0].Rows[0]["Dept_ID"].ToString() != "")
                {
                    model.Dept_ID = int.Parse(ds.Tables[0].Rows[0]["Dept_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);
            }
        }