Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request["index"] != null)
         {
             int index = Convert.ToInt32(Request["index"]);
             if (Session["Orders"] != null)
             {
                 List <TB_POOrders> POOrders = Session["Orders"] as List <TB_POOrders>;
                 TB_POOrders        model    = POOrders[index];
                 setValue(model);
             }
         }
     }
 }
Example #2
0
        private void setValue(TB_POOrders model)
        {
            txtCostPrice.Text = Convert.ToDecimal(model.CostPrice).ToString();
            txtGuestName.Text = model.GuestName;
            txtInvName.Text   = model.InvName;
            txtNum.Text       = model.Num.ToString();
            txtOtherCost.Text = model.OtherCost.ToString();
            if (model.Profit != null)
            {
                txtProfit.Text = string.Format("{0:n2}", model.Profit.Value);
            }
            txtSellPrice.Text = model.SellPrice.ToString();
            txtTime.Text      = model.Time.ToShortDateString();
            if (model.ToTime != null)
            {
                txtToTime.Text = model.ToTime.Value.ToShortDateString();
            }
            txtUnit.Text = model.Unit;


            txtCostTotal.Text = string.Format("{0:n2}", model.Num * model.CostPrice);
            txtSellTotal.Text = string.Format("{0:n2}", model.SellPrice * model.Num);
        }
Example #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Convert.ToDecimal(txtSellPrice.Text);
                Convert.ToDecimal(txtCostPrice.Text);
            }
            catch (Exception)
            {
                base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('你填写的单价格式有误!');</script>");
                return;
            }
            TB_POOrders s = new TB_POOrders();

            s.Unit      = txtUnit.Text;
            s.CostPrice = Convert.ToDecimal(txtCostPrice.Text);
            s.GuestName = txtGuestName.Text;
            s.InvName   = txtInvName.Text;
            s.Num       = Convert.ToDecimal(txtNum.Text);
            if (txtOtherCost.Text != "")
            {
                s.OtherCost = Convert.ToDecimal(txtOtherCost.Text);
            }
            if (txtProfit.Text != "")
            {
                s.Profit = Convert.ToDecimal(txtProfit.Text);
            }

            s.SellPrice = Convert.ToDecimal(txtSellPrice.Text);

            s.Time = Convert.ToDateTime(txtTime.Text);
            if (txtToTime.Text != "")
            {
                s.ToTime = Convert.ToDateTime(txtToTime.Text);
            }

            s.CostTotal = s.CostPrice * s.Num;
            s.SellTotal = s.SellPrice * s.Num;
            s.YiLiTotal = s.SellTotal - s.CostTotal - s.OtherCost;
            if (s.SellTotal != 0)
            {
                s.Profit = s.YiLiTotal / s.SellTotal * 100;
            }
            else if (s.YiLiTotal != 0)
            {
                s.Profit = -100;
            }
            else
            {
                s.Profit = 0;
            }
            //修改
            if (Request["index"] != null)
            {
                int index = Convert.ToInt32(Request["index"]);
                if (Session["Orders"] != null)
                {
                    List <TB_POOrders> POOrders = Session["Orders"] as List <TB_POOrders>;

                    TB_POOrders model   = POOrders[index];
                    TB_POOrders newSche = s;
                    s.Ids             = model.Ids;
                    newSche.IfUpdate  = true;
                    POOrders[index]   = newSche;
                    Session["Orders"] = POOrders;
                }
                this.ClientScript.RegisterStartupScript(this.GetType(), null, "<script> window.close();</script>");
            }
            else
            {
                if (Session["Orders"] == null)
                {
                    List <TB_POOrders> POOrders = new List <TB_POOrders>();
                    POOrders.Insert(POOrders.Count, s);
                    Session["Orders"] = POOrders;
                }
                else
                {
                    List <TB_POOrders> POOrders = Session["Orders"] as List <TB_POOrders>;
                    POOrders.Insert(POOrders.Count, s);
                    Session["Orders"] = POOrders;
                }
                clear();
            }
            // this.ClientScript.RegisterStartupScript(this.GetType(), null, "<script> window.close();</script>");
        }