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

            if (!PageValidate.IsDateTime(txtWriteDate.Text))
            {
                strErr += "WriteDate格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtInsureDate.Text))
            {
                strErr += "InsureDate格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtEndDate.Text))
            {
                strErr += "EndDate格式错误!\\n";
            }
            //if (!PageValidate.IsNumber(txtDept_ID.Text))
            //{
            //    strErr += "Dept_ID格式错误!\\n";
            //}
            //if (!PageValidate.IsNumber(txtSupplier_ID.Text))
            //{
            //    strErr += "Supplier_ID格式错误!\\n";
            //}
            //if (!PageValidate.IsNumber(txtEmployee_ID.Text))
            //{
            //    strErr += "Employee_ID格式错误!\\n";
            //}

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      BuyOrder_ID = int.Parse(this.lblBuyOrder_ID.Text);
            DateTime WriteDate   = DateTime.Parse(this.txtWriteDate.Text);
            DateTime InsureDate  = DateTime.Parse(this.txtInsureDate.Text);
            DateTime EndDate     = DateTime.Parse(this.txtEndDate.Text);
            int      Dept_ID     = int.Parse(this.DropDownList1.SelectedValue);
            int      Supplier_ID = int.Parse(this.DropDownList2.SelectedValue);
            int      Employee_ID = int.Parse(this.DropDownList3.SelectedValue);


            ZhangWei.Model.BuyOrder model = new ZhangWei.Model.BuyOrder();
            model.BuyOrder_ID = BuyOrder_ID;
            model.WriteDate   = WriteDate;
            model.InsureDate  = InsureDate;
            model.EndDate     = EndDate;
            model.Dept_ID     = Dept_ID;
            model.Supplier_ID = Supplier_ID;
            model.Employee_ID = Employee_ID;

            ZhangWei.BLL.BuyOrder bll = new ZhangWei.BLL.BuyOrder();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Beispiel #2
0
 private void ShowInfo(int BuyOrder_ID)
 {
     ZhangWei.BLL.BuyOrder   bll   = new ZhangWei.BLL.BuyOrder();
     ZhangWei.Model.BuyOrder model = bll.GetModel(BuyOrder_ID);
     this.lblBuyOrder_ID.Text = model.BuyOrder_ID.ToString();
     this.lblWriteDate.Text   = model.WriteDate.ToString();
     this.lblInsureDate.Text  = model.InsureDate.ToString();
     this.lblEndDate.Text     = model.EndDate.ToString();
     this.lblDept_ID.Text     = model.Dept_ID.ToString();
     this.lblSupplier_ID.Text = model.Supplier_ID.ToString();
     this.lblEmployee_ID.Text = model.Employee_ID.ToString();
 }
Beispiel #3
0
 private void ShowInfo(int BuyOrder_ID)
 {
     ZhangWei.BLL.BuyOrder   bll   = new ZhangWei.BLL.BuyOrder();
     ZhangWei.Model.BuyOrder model = bll.GetModel(BuyOrder_ID);
     this.lblBuyOrder_ID.Text = model.BuyOrder_ID.ToString();
     this.txtWriteDate.Text   = model.WriteDate.ToString();
     this.txtInsureDate.Text  = model.InsureDate.ToString();
     this.txtEndDate.Text     = model.EndDate.ToString();
     //this.txtDept_ID.Text = model.Dept_ID.ToString();
     //this.txtSupplier_ID.Text = model.Supplier_ID.ToString();
     //this.txtEmployee_ID.Text = model.Employee_ID.ToString();
     DropDownList1.SelectedValue = model.Dept_ID.ToString();
     DropDownList2.SelectedValue = model.Supplier_ID.ToString();
     DropDownList3.SelectedValue = model.Employee_ID.ToString();
 }
Beispiel #4
0
 private void ShowInfo(int BuyOrder_ID)
 {
     ZhangWei.BLL.BuyOrder   bll   = new ZhangWei.BLL.BuyOrder();
     ZhangWei.Model.BuyOrder model = bll.GetModel(BuyOrder_ID);
     this.lblBuyOrder_ID.Text = "(合同编号:" + model.BuyOrder_ID.ToString() + ")";
     this.txtWriteDate.Text   = model.WriteDate.ToString();
     this.txtInsureDate.Text  = model.InsureDate.ToString();
     this.txtEndDate.Text     = model.EndDate.ToString();
     //this.txtDept_ID.Text = model.Dept_ID.ToString();
     //this.txtSupplier_ID.Text = model.Supplier_ID.ToString();
     //this.txtEmployee_ID.Text = model.Employee_ID.ToString();
     DropDownList1.SelectedValue = model.Dept_ID.ToString();
     //DropDownList2.SelectedValue = model.Supplier_ID.ToString();
     DropDownList3.SelectedValue = model.Employee_ID.ToString();
     Button1.Attributes.Add("onclick", "return confirm(\"确认入库吗?\")");
 }
Beispiel #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ZhangWei.Model.BuyOrder model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BuyOrder set ");
            strSql.Append("WriteDate=@WriteDate,");
            strSql.Append("InsureDate=@InsureDate,");
            strSql.Append("EndDate=@EndDate,");
            strSql.Append("Dept_ID=@Dept_ID,");
            strSql.Append("Supplier_ID=@Supplier_ID,");
            strSql.Append("Employee_ID=@Employee_ID,");
            strSql.Append("Produced=@Produced");
            strSql.Append(" where BuyOrder_ID=@BuyOrder_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@WriteDate",   SqlDbType.DateTime),
                new SqlParameter("@InsureDate",  SqlDbType.DateTime),
                new SqlParameter("@EndDate",     SqlDbType.DateTime),
                new SqlParameter("@Dept_ID",     SqlDbType.Int,       4),
                new SqlParameter("@Supplier_ID", SqlDbType.Int,       4),
                new SqlParameter("@Employee_ID", SqlDbType.Int,       4),
                new SqlParameter("@Produced",    SqlDbType.Bit,       1),
                new SqlParameter("@BuyOrder_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.WriteDate;
            parameters[1].Value = model.InsureDate;
            parameters[2].Value = model.EndDate;
            parameters[3].Value = model.Dept_ID;
            parameters[4].Value = model.Supplier_ID;
            parameters[5].Value = model.Employee_ID;
            parameters[6].Value = model.Produced;
            parameters[7].Value = model.BuyOrder_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ZhangWei.Model.BuyOrder model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BuyOrder(");
            strSql.Append("WriteDate,InsureDate,EndDate,Dept_ID,Supplier_ID,Employee_ID,Produced)");
            strSql.Append(" values (");
            strSql.Append("@WriteDate,@InsureDate,@EndDate,@Dept_ID,@Supplier_ID,@Employee_ID,@Produced)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@WriteDate",   SqlDbType.DateTime),
                new SqlParameter("@InsureDate",  SqlDbType.DateTime),
                new SqlParameter("@EndDate",     SqlDbType.DateTime),
                new SqlParameter("@Dept_ID",     SqlDbType.Int,       4),
                new SqlParameter("@Supplier_ID", SqlDbType.Int,       4),
                new SqlParameter("@Employee_ID", SqlDbType.Int,       4),
                new SqlParameter("@Produced",    SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.WriteDate;
            parameters[1].Value = model.InsureDate;
            parameters[2].Value = model.EndDate;
            parameters[3].Value = model.Dept_ID;
            parameters[4].Value = model.Supplier_ID;
            parameters[5].Value = model.Employee_ID;
            parameters[6].Value = model.Produced;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZhangWei.Model.BuyOrder GetModel(int BuyOrder_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 BuyOrder_ID,WriteDate,InsureDate,EndDate,Dept_ID,Supplier_ID,Employee_ID,Produced from BuyOrder ");
            strSql.Append(" where BuyOrder_ID=@BuyOrder_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BuyOrder_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = BuyOrder_ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["BuyOrder_ID"] != null && ds.Tables[0].Rows[0]["BuyOrder_ID"].ToString() != "")
                {
                    model.BuyOrder_ID = int.Parse(ds.Tables[0].Rows[0]["BuyOrder_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["WriteDate"] != null && ds.Tables[0].Rows[0]["WriteDate"].ToString() != "")
                {
                    model.WriteDate = DateTime.Parse(ds.Tables[0].Rows[0]["WriteDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["InsureDate"] != null && ds.Tables[0].Rows[0]["InsureDate"].ToString() != "")
                {
                    model.InsureDate = DateTime.Parse(ds.Tables[0].Rows[0]["InsureDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EndDate"] != null && ds.Tables[0].Rows[0]["EndDate"].ToString() != "")
                {
                    model.EndDate = DateTime.Parse(ds.Tables[0].Rows[0]["EndDate"].ToString());
                }
                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());
                }
                if (ds.Tables[0].Rows[0]["Employee_ID"] != null && ds.Tables[0].Rows[0]["Employee_ID"].ToString() != "")
                {
                    model.Employee_ID = int.Parse(ds.Tables[0].Rows[0]["Employee_ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Produced"] != null && ds.Tables[0].Rows[0]["Produced"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Produced"].ToString() == "1") || (ds.Tables[0].Rows[0]["Produced"].ToString().ToLower() == "true"))
                    {
                        model.Produced = true;
                    }
                    else
                    {
                        model.Produced = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }