Пример #1
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public VAN_OA.Model.EFrom.Tb_ProjectInvs ReaderBind(IDataReader dataReader)
        {
            Model.EFrom.Tb_ProjectInvs model = new Model.EFrom.Tb_ProjectInvs();
            object ojb;

            ojb = dataReader["Id"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Id = (int)ojb;
            }
            ojb = dataReader["PId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.PId = (int)ojb;
            }
            ojb = dataReader["BuyTime"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.BuyTime = (DateTime)ojb;
            }
            model.InvModel = dataReader["InvModel"].ToString();
            model.InvName  = dataReader["InvName"].ToString();
            model.InvUnit  = dataReader["InvUnit"].ToString();
            ojb            = dataReader["InvNum"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InvNum = (decimal)ojb;
            }
            ojb = dataReader["InvPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InvPrice = (decimal)ojb;
            }
            ojb = dataReader["InvCarPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InvCarPrice = (decimal)ojb;
            }
            ojb = dataReader["InvTaskPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InvTaskPrice = (decimal)ojb;
            }
            ojb = dataReader["InvManPrice"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.InvManPrice = (decimal)ojb;
            }
            model.Remark = dataReader["Remark"].ToString();
            ojb          = dataReader["Total"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Total = Convert.ToDecimal(ojb);
            }

            return(model);
        }
Пример #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (txtBuyTime.Text.Trim() == "")
            {
                base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('请填写购买日期!');</script>");
                txtBuyTime.Focus();
                return;
            }
            else
            {
                try
                {
                    Convert.ToDateTime(txtBuyTime.Text);
                }
                catch (Exception)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('购买日期格式错误!');</script>");
                    txtBuyTime.Focus();
                    return;
                }
            }
            if (txtInvName.Text.Trim() == "")
            {
                base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('材料名称不能为空!');</script>");
                txtInvName.Focus();
                return;
            }

            if (txtInvNum.Text.Trim() == "")
            {
                base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('数量不能为空!');</script>");
                txtInvName.Focus();
                return;
            }
            else
            {
                try
                {
                    Convert.ToDecimal(txtInvNum.Text);
                }
                catch (Exception)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('数量格式错误!');</script>");
                    txtBuyTime.Focus();
                    return;
                }


                try
                {
                    if (txtInvPrice.Text != "")
                    {
                        Convert.ToDecimal(txtInvPrice.Text);
                    }
                }
                catch (Exception)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('材料费格式错误!');</script>");
                    txtInvPrice.Focus();
                    return;
                }



                try
                {
                    if (txtInvCarPrice.Text != "")
                    {
                        Convert.ToDecimal(txtInvCarPrice.Text);
                    }
                }
                catch (Exception)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('运费格式错误!');</script>");
                    txtInvCarPrice.Focus();
                    return;
                }


                try
                {
                    if (txtInvTaskPrice.Text != "")
                    {
                        Convert.ToDecimal(txtInvTaskPrice.Text);
                    }
                }
                catch (Exception)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('会务费格式错误!');</script>");
                    txtInvTaskPrice.Focus();
                    return;
                }

                try
                {
                    if (txtInvManPrice.Text != "")
                    {
                        Convert.ToDecimal(txtInvManPrice.Text);
                    }
                }
                catch (Exception)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('管理费格式错误!');</script>");
                    txtInvManPrice.Focus();
                    return;
                }
            }
            DateTime BuyTime  = DateTime.Parse(this.txtBuyTime.Text);
            decimal  total    = 0;
            string   InvModel = this.txtInvModel.Text;
            string   InvName  = this.txtInvName.Text;
            string   InvUnit  = this.txtInvUnit.Text;
            decimal  InvNum   = decimal.Parse(this.txtInvNum.Text);
            decimal? InvPrice = null;

            if (txtInvPrice.Text != "")
            {
                InvPrice = decimal.Parse(this.txtInvPrice.Text);

                total += decimal.Parse(this.txtInvPrice.Text);
            }

            decimal?InvCarPrice = null;

            if (txtInvCarPrice.Text != "")
            {
                InvCarPrice = decimal.Parse(this.txtInvCarPrice.Text);
                total      += decimal.Parse(this.txtInvCarPrice.Text);
            }


            decimal?InvTaskPrice = null;

            if (txtInvTaskPrice.Text != "")
            {
                InvTaskPrice = decimal.Parse(this.txtInvTaskPrice.Text);
                total       += decimal.Parse(this.txtInvTaskPrice.Text);
            }


            decimal?InvManPrice = null;

            if (txtInvManPrice.Text != "")
            {
                InvManPrice = decimal.Parse(this.txtInvManPrice.Text);
                total      += decimal.Parse(this.txtInvManPrice.Text);
            }


            string Remark = this.txtRemark.Text;


            Model.EFrom.Tb_ProjectInvs model = new Model.EFrom.Tb_ProjectInvs();
            model.Total        = total;
            model.BuyTime      = BuyTime;
            model.InvModel     = InvModel;
            model.InvName      = InvName;
            model.InvUnit      = InvUnit;
            model.InvNum       = InvNum;
            model.InvPrice     = InvPrice;
            model.InvCarPrice  = InvCarPrice;
            model.InvTaskPrice = InvTaskPrice;
            model.InvManPrice  = InvManPrice;
            model.Remark       = Remark;
            if (ViewState["state"] != null)
            {
                if (ViewState["state"].ToString() == "add")
                {
                    List <Tb_ProjectInvs> POOrders = Session["ProInvs"] as List <Tb_ProjectInvs>;
                    POOrders.Add(model);
                    Session["ProInvs"] = POOrders;
                    setTotal(POOrders);
                    gvList.DataSource = POOrders;
                    gvList.DataBind();

                    this.txtBuyTime.Text      = "";
                    this.txtInvModel.Text     = "";
                    this.txtInvName.Text      = "";
                    this.txtInvUnit.Text      = "";
                    this.txtInvNum.Text       = "";
                    this.txtInvPrice.Text     = "";
                    this.txtInvCarPrice.Text  = "";
                    this.txtInvTaskPrice.Text = "";
                    this.txtInvManPrice.Text  = "";
                    this.txtRemark.Text       = "";
                    ViewState["state"]        = "add";
                    return;
                }
                if (ViewState["state"].ToString() == "edit" && ViewState["index"] != null)
                {
                    int index = Convert.ToInt32(ViewState["index"]);
                    if (Session["ProInvs"] != null)
                    {
                        List <Tb_ProjectInvs> POOrders = Session["ProInvs"] as List <Tb_ProjectInvs>;

                        Tb_ProjectInvs modelPro = POOrders[index];

                        model.Id           = modelPro.Id;
                        model.IfUpdate     = true;
                        POOrders[index]    = model;
                        Session["ProInvs"] = POOrders;
                        setTotal(POOrders);
                        gvList.DataSource = POOrders;
                        gvList.DataBind();
                    }
                }
            }

            btnAdd.Enabled    = true;
            btnSave.Enabled   = false;
            btnCancel.Enabled = false;
        }
Пример #3
0
        /// <summary>
        /// 获得数据列表(比DataSet效率高,推荐使用)
        /// </summary>
        public List <VAN_OA.Model.EFrom.Tb_ProjectInvs> GetListArray_Rep(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * ");
            strSql.Append(" FROM Tb_ProjectInv_View ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }

            strSql.Append(" order by ProNo desc ");
            List <VAN_OA.Model.EFrom.Tb_ProjectInvs> list = new List <VAN_OA.Model.EFrom.Tb_ProjectInvs>();

            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        Model.EFrom.Tb_ProjectInvs model = new Model.EFrom.Tb_ProjectInvs();
                        object ojb;
                        ojb = dataReader["Id"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Id = (int)ojb;
                        }
                        //ojb = dataReader["PId"];
                        //if (ojb != null && ojb != DBNull.Value)
                        //{
                        //    model.PId = (int)ojb;
                        //}
                        ojb = dataReader["BuyTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.BuyTime = (DateTime)ojb;
                        }
                        model.InvModel = dataReader["InvModel"].ToString();
                        model.InvName  = dataReader["InvName"].ToString();
                        model.InvUnit  = dataReader["InvUnit"].ToString();
                        ojb            = dataReader["InvNum"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvNum = (decimal)ojb;
                        }
                        ojb = dataReader["InvPrice"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvPrice = (decimal)ojb;
                        }
                        ojb = dataReader["InvCarPrice"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvCarPrice = (decimal)ojb;
                        }
                        ojb = dataReader["InvTaskPrice"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvTaskPrice = (decimal)ojb;
                        }
                        ojb = dataReader["InvManPrice"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.InvManPrice = (decimal)ojb;
                        }
                        model.Remark = dataReader["Remark"].ToString();


                        ojb = dataReader["CreateTime"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.CreateTime = (DateTime)ojb;
                        }
                        model.ProNo   = dataReader["ProNo"].ToString();
                        model.ProName = dataReader["ProName"].ToString();

                        ojb = dataReader["loginName"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.LoginName = ojb.ToString();
                        }
                        ojb = dataReader["State"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.State = ojb.ToString();
                        }

                        ojb = dataReader["Total"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.Total = Convert.ToDecimal(ojb);
                        }

                        ojb = dataReader["guestName"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.GuestName = ojb.ToString();
                        }
                        ojb = dataReader["efState"];
                        if (ojb != null && ojb != DBNull.Value)
                        {
                            model.EfState = ojb.ToString();
                        }


                        list.Add(model);
                    }
                }
            }
            return(list);
        }