private void AddData_Click(object sender, RoutedEventArgs e) { if (txtContainer.Text == "" || txtMessage.Text == "") { txtContainer.Text = "0"; txtMessage.Text = "ไม่มี"; } if (txtProductid.Text == "" || txtNameproduct.Text == "" || txtTotal.Text == "" || txtContainer.Text == "" || txtTotal.Text == "" || txtInfototal.Text == "" || txtPrice.Text == "" || txttotalPrice.Text == "") { System.Windows.MessageBox.Show("กรุณากรอกข้อมูลให้ครบ"); return; } dataGrid.Items.Add(new DataBuytoday() { Code = txtProductid.Text, Name = txtNameproduct.Text, Ptotal = txtTotal.Text, Dtotal = txtContainer.Text, Atotal = intSum.ToString(), Mtotal = txtInfototal.Text, Price = txtPrice.Text, Typenub = txtUnit.Text, Tprice = txttotalPrice.Text, Note = txtMessage.Text }); this.DataContext = dataGrid; LastTotal += plTotal; TotalLast.Text = LastTotal.ToString(); txtProductid.Text = ""; txtNameproduct.Text = ""; txtPrice.Text = ""; txtUnit.Text = ""; txtTotal.Text = ""; txtContainer.Text = ""; txtSubtotal.Text = ""; txtInfototal.Text = ""; txttotalPrice.Text = ""; txtMessage.Text = ""; dataGrid.SelectedIndex = 0; }
private void Update_Click(object sender, RoutedEventArgs e) { if (dataGrid.SelectedItem != null) { DataBuytoday item = (DataBuytoday)dataGrid.SelectedItem; // หักลบเงินหลังจากไปอีกหน้า TotalLast.Text = item.Tprice; plTotal = Double.Parse(TotalLast.Text); LastTotal -= plTotal; TotalLast.Text = LastTotal.ToString(); /// EditProduct go = new EditProduct(); go.txtCode.Text = item.Code; go.txtUnit.Text = item.Ptotal; go.txtTotal.Text = item.Atotal; go.txtType.Text = item.Typenub; go.txtNote.Text = item.Mtotal; go.txtMessage.Text = item.Note; go.txtName.Text = item.Name; go.txtDelete.Text = item.Dtotal; go.txtPrice.Text = item.Price; go.txtTotalPrice.Text = item.Tprice; go.ShowDialog(); item.Code = go.getCode; item.Name = go.getName; item.Ptotal = go.getUnit; item.Dtotal = go.getDelete; item.Atotal = go.getAllTotal; item.Price = go.getPrice; item.Typenub = go.getType; item.Tprice = go.getTotalprice; item.Note = go.getMessage; item.Mtotal = go.getNote; // คำนวณเงินที่ได้จากการแก้ไขมาแล้ว plTotal = Double.Parse(go.txtTotalPrice.Text); LastTotal += plTotal; TotalLast.Text = LastTotal.ToString(); // dataGrid.Items.Refresh(); } }
/// <summary> /// Ported from changed_value_posts::output_intermediate_prices /// </summary> public void OutputIntermediatePrices(Post post, Date current) { // To fix BZ#199, examine the balance of last_post and determine whether the // price of that amount changed after its date and before the new post's // date. If so, generate an output_revaluation for that price change. // Mostly this is only going to occur if the user has a series of pricing // entries, since a posting-based revaluation would be seen here as a post. Value displayTotal = Value.Clone(LastTotal); if (displayTotal.Type == ValueTypeEnum.Sequence) { Xact xact = Temps.CreateXact(); xact.Payee = "Commodities revalued"; xact.Date = current.IsValid() ? current : post.ValueDate; Post temp = Temps.CopyPost(post, xact); temp.Flags |= SupportsFlagsEnum.ITEM_GENERATED; PostXData xdata = temp.XData; if (current.IsValid()) { xdata.Date = current; } Logger.Current.Debug("filters.revalued", () => String.Format("intermediate last_total = {0}", LastTotal)); switch (LastTotal.Type) { case ValueTypeEnum.Boolean: case ValueTypeEnum.Integer: LastTotal.InPlaceCast(ValueTypeEnum.Amount); temp.Amount = LastTotal.AsAmount; break; case ValueTypeEnum.Amount: temp.Amount = LastTotal.AsAmount; break; case ValueTypeEnum.Balance: case ValueTypeEnum.Sequence: xdata.CompoundValue = LastTotal; xdata.Compound = true; break; default: throw new InvalidOperationException(); } BindScope innerScope = new BindScope(Report, temp); displayTotal = DisplayTotalExpr.Calc(innerScope); Logger.Current.Debug("filters.revalued", () => String.Format("intermediate display_total = {0}", displayTotal)); } switch (displayTotal.Type) { case ValueTypeEnum.Void: case ValueTypeEnum.Integer: case ValueTypeEnum.Sequence: break; case ValueTypeEnum.Amount: case ValueTypeEnum.Balance: { if (displayTotal.Type == ValueTypeEnum.Amount) { displayTotal.InPlaceCast(ValueTypeEnum.Balance); } IDictionary <DateTime, Amount> allPrices = new SortedDictionary <DateTime, Amount>(); foreach (KeyValuePair <Commodity, Amount> amtComm in displayTotal.AsBalance.Amounts) { amtComm.Key.MapPrices((d, a) => allPrices[d] = a, current, post.ValueDate, true); } // Choose the last price from each day as the price to use IDictionary <Date, bool> pricingDates = new SortedDictionary <Date, bool>(); foreach (KeyValuePair <DateTime, Amount> price in allPrices.Reverse()) { // This insert will fail if a later price has already been inserted // for that date. var priceDate = (Date)price.Key.Date; Logger.Current.Debug("filters.revalued", () => String.Format("re-inserting {0} at {1}", price.Value, priceDate)); pricingDates[priceDate] = true; } // Go through the time-sorted prices list, outputting a revaluation for // each price difference. foreach (KeyValuePair <Date, bool> price in pricingDates) { OutputRevaluation(post, price.Key); LastTotal = RepricedTotal; } break; } default: throw new InvalidOperationException(); } }