private void EventSink_BarcodeScanned(object sender, BarcodeScannedEventArgs args) { if (args.Barcode != string.Empty) { using (MuhasebeEntities m_Context = new MuhasebeEntities()) { string m_Barcode = args.Barcode; var m_Item = m_Context.Items.Where(q => q.Inventory.OwnerID == Program.User.WorksAtID && q.Product.Barcode == m_Barcode).FirstOrDefault(); if (m_Item == null) { this.Invoke((MethodInvoker) delegate() { Add_Item_Pop m_Pop = new Add_Item_Pop(m_Barcode); m_Pop.ShowDialog(); }); } else { InvoiceNode m_Node = new InvoiceNode(m_Item); m_Node.Amount = 1; m_Node.FinalPrice = m_Node.BasePrice * m_Node.Amount; this.Append(m_Node); } } } }
private void NodeAmountChanged(dynamic node) { InvoiceNode m_Actual = this.Invoice.Nodes.Where(q => q.ItemID == node.ItemID).FirstOrDefault(); if (m_Actual != null) { m_Actual.Amount = node.Amount; } this.PopulateListView(); }
public void Append(InvoiceNode node) { if (node.ItemID < 0 || this.Invoice.Nodes.Any(q => q.ItemID == node.ItemID) == false) { node.InvoiceID = this.Invoice.ID; this.Invoice.Nodes.Add(node); } else if (node.ItemID > 0) { this.Invoice.Nodes.Where(q => q.ItemID == node.ItemID).FirstOrDefault().Amount += node.Amount; } PopulateListView(); }
private void Manage_Sales_Mdi_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Multiply) { if (this.Invoice.Nodes.Count > 0) { InvoiceNode m_Node = this.Invoice.Nodes.LastOrDefault(); Node_Set_Amount_Gumpling m_Gumpling = new Node_Set_Amount_Gumpling(); m_Gumpling.Node = m_Node; m_Gumpling.NodeAmountChanged += NodeAmountChanged; m_Gumpling.ShowDialog(); } } }
private void düzenleToolStripMenuItem_Click(object sender, EventArgs e) { if (this.Edit_Sale_List.SelectedItems.Count == 1) { int m_ItemID = Convert.ToInt32(this.Edit_Sale_List.SelectedItems[0].Tag); InvoiceNode m_Node = this.Invoice.Nodes.Where(q => q.ItemID == m_ItemID).FirstOrDefault(); if (m_Node != null) { Node_Set_Amount_Gumpling m_Gumpling = new Node_Set_Amount_Gumpling(); m_Gumpling.Node = m_Node; m_Gumpling.NodeAmountChanged += NodeAmountChanged; m_Gumpling.ShowDialog(); } } }
private void Sale_Button_Click(object sender, EventArgs e) { if (this.Item != null) { InvoiceNode m_Node = new InvoiceNode(this.Item); m_Node.Amount = this.Amount_Num.Value; m_Node.BasePrice = this.PerPrice_Num.Value; m_Node.FinalPrice = this.TotalPrice_Num.Value; if (this.UseCustumPricing_Check.Checked) { m_Node.UseCustomPrice = true; } InvoiceNodeCreated?.Invoke(m_Node); } this.Close(); }
private void silToolStripMenuItem_Click(object sender, EventArgs e) { if (this.Edit_Sale_List.SelectedItems.Count > 0) { if (MessageBox.Show(string.Format("Seçili {0} objeyi silmek istediğinizden emin misiniz?", this.Edit_Sale_List.SelectedItems.Count), "Dikkat", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { foreach (ListViewItem m_ViewItem in this.Edit_Sale_List.SelectedItems) { int m_ItemID = Convert.ToInt32(m_ViewItem.Tag); InvoiceNode m_Node = this.Invoice.Nodes.Where(q => q.ItemID == m_ItemID).FirstOrDefault(); if (m_Node != null) { this.Invoice.Nodes.Remove(m_Node); } } PopulateListView(); } } }
private void Pop_InvoiceNodeCreated(InvoiceNode node) { this.Append(node); }
private void Save_Button_Click(object sender, EventArgs e) { int m_PaymentTypeID = Convert.ToInt32(this.Payment_Combo.SelectedValue); if (m_PaymentTypeID == 3 && this.Account_Box.SelectedValue == null) { MessageBox.Show("Vadeli satışı ancak bir cari hesaba yapabilirsiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using (MuhasebeEntities m_Context = new MuhasebeEntities()) { if (this.Invoice != null && this.Invoice.Nodes.Count > 0) { this.Invoice.OwnerID = Program.User.WorksAtID.Value; this.Invoice.PaymentTypeID = Convert.ToInt32(this.Payment_Combo.SelectedValue); //this.Invoice.CreatedAt = DateTime.Now; this.Invoice.AuthorID = Program.User.ID; this.Invoice.State = "Complete"; decimal m_Total = 0; decimal m_Tax = 0; this.Invoice.Nodes.All(delegate(InvoiceNode m_Node) { m_Total += m_Node.FinalPrice.Value; m_Tax += m_Node.FinalPrice.Value * ((decimal)(m_Node.Tax.Value / 100)); /*if (this.Decrease_Stock_Check.Checked && m_Node.Item != null) * m_Context.Items.Where(q => q.ID == m_Node.ItemID).FirstOrDefault().Amount -= m_Node.Amount.Value; * * m_Node.Invoice = this.Invoice; * m_Node.Item = null;*/ return(true); }); if (this.Invoice.Discount.HasValue) { m_Total = m_Total - this.Invoice.Discount.Value; } Invoice m_Actual = m_Context.Invoices.Where(q => q.ID == this.Invoice.ID).FirstOrDefault(); m_Actual.OwnerID = this.Invoice.OwnerID; m_Actual.AuthorID = this.Invoice.AuthorID; m_Actual.CreatedAt = this.Invoice.CreatedAt; m_Actual.Discount = this.Invoice.Discount; m_Actual.PaymentTypeID = this.Invoice.PaymentTypeID; m_Actual.State = this.Invoice.State; m_Actual.TargetID = this.Invoice.TargetID; var m_Added = this.Invoice.Nodes.Except(m_Actual.Nodes, (p, p1) => p.ItemID == p1.ItemID).ToList(); var m_Deleted = m_Actual.Nodes.Except(this.Invoice.Nodes, (p, p1) => p.ItemID == p1.ItemID).ToList(); var m_Changed = m_Actual.Nodes.Intersect(this.Invoice.Nodes, (p, p1) => p.ItemID == p1.ItemID && (p.Amount != p1.Amount || p.BasePrice != p1.BasePrice || p.UseCustomPrice != p1.UseCustomPrice)).ToList(); m_Added.All(delegate(InvoiceNode m_Node) { if (Decrease_Stock_Check.Checked && m_Node.ItemID > 0) { m_Context.Items.Where(q => q.ID == m_Node.ItemID).FirstOrDefault().Amount -= m_Node.Amount.Value; } m_Actual.Nodes.Add(m_Node); return(true); }); m_Deleted.All(delegate(InvoiceNode m_Node) { if (Increase_Stock_Check.Checked && m_Node.ItemID > 0) { m_Context.Items.Where(q => q.ID == m_Node.ItemID).FirstOrDefault().Amount += m_Node.Amount.Value; } InvoiceNode m_ToDelete = m_Actual.Nodes.Where(q => q.ItemID == m_Node.ItemID).FirstOrDefault(); m_Actual.Nodes.Remove(m_ToDelete); m_Context.Entry(m_ToDelete).State = System.Data.Entity.EntityState.Deleted; return(true); }); m_Changed.All(delegate(InvoiceNode m_Node) { InvoiceNode m_Knode = this.Invoice.Nodes.Where(q => q.ItemID == m_Node.ItemID).FirstOrDefault(); if (m_Knode != null) { if (m_Node.Amount > m_Knode.Amount) { // Bazıları silinmiş if (m_Node.ItemID > 0 && Increase_Stock_Check.Checked) //Eğer kayıt dışı satış değilse { m_Context.Items.Where(q => q.ID == m_Node.ItemID).FirstOrDefault().Amount += m_Node.Amount.Value - m_Knode.Amount.Value; } } else if (m_Node.Amount < m_Knode.Amount) { if (m_Node.ItemID > 0 && Decrease_Stock_Check.Checked) // Kayıt dışı satış değisle { m_Context.Items.Where(q => q.ID == m_Node.ItemID).FirstOrDefault().Amount -= m_Knode.Amount.Value - m_Node.Amount.Value; } } m_Node.Amount = m_Knode.Amount; m_Node.BasePrice = m_Knode.BasePrice; m_Node.FinalPrice = m_Knode.FinalPrice; m_Node.UseCustomPrice = m_Knode.UseCustomPrice; if (m_Node.UseCustomPrice == null) { m_Node.UseCustomPrice = false; } } return(true); }); m_Actual.Nodes.All(delegate(InvoiceNode m_Node) { m_Node.Invoice = m_Actual; m_Node.Item = null; return(true); }); if (m_Actual.PaymentTypeID != 3) // Vadeli değil { Income m_Income = m_Context.Incomes.Where(q => q.InvoiceID == m_Actual.ID).FirstOrDefault(); m_Income.Amount = m_Total; } AccountMovement m_Movement = m_Context.AccountMovements.Where(q => q.AccountID == m_Actual.TargetID && q.ContractID == m_Actual.ID && q.MovementTypeID == 1).FirstOrDefault(); if (m_Movement != null) { m_Movement.Value = m_Total; } m_Context.SaveChanges(); this.Close(); } else { MessageBox.Show("Satılabilecek herhangi bir ürün yok.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void Node_Set_Amount_Gumpling_Load(object sender, EventArgs e) { if (this.Node == null) { this.Close(); } if (this.Node is InvoiceNode) { InvoiceNode m_Temp = this.Node as InvoiceNode; if (m_Temp.Item != null) { this.Name_Label.Text = m_Temp.Item.Product.Name; } else { this.Name_Label.Text = m_Temp.Description; } this.Amount_Num.Value = m_Temp.Amount.Value; this.UnitPrice_Num.Value = m_Temp.BasePrice.Value; } else if (this.Node is StockMovementNode) { StockMovementNode m_Temp = this.Node as StockMovementNode; this.Name_Label.Text = m_Temp.Item.Product.Name; this.Amount_Num.Value = m_Temp.Amount; this.UnitPrice_Num.Value = m_Temp.BasePrice.Value; } else if (this.Node is OfferNode) { OfferNode m_Temp = this.Node as OfferNode; this.Name_Label.Text = m_Temp.Item.Product.Name; this.Amount_Num.Value = m_Temp.Amount; this.UnitPrice_Num.Value = m_Temp.BasePrice; this.Description_Box.Text = m_Temp.Description; this.Description_Label.Visible = true; this.Description_Box.Visible = true; } if (this.Node.Item != null) { this.Amount_Num.DecimalPlaces = this.Node.Item.UnitType.DecimalPlaces; if (this.Amount_Num.DecimalPlaces == 0) { this.Amount_Num.Minimum = 1m; } else if (this.Amount_Num.DecimalPlaces == 2) { this.Amount_Num.Minimum = 0.01m; } else if (this.Amount_Num.DecimalPlaces == 4) { this.Amount_Num.Minimum = 0.0001m; } this.UnitPrice_Num.Minimum = 0.01m; } this.Amount_Num.Focus(); this.Amount_Num.Select(0, this.Amount_Num.Value.ToString().Length); }
internal void Append(InvoiceNode m_Node) { throw new NotImplementedException(); }
private void EventSink_BarcodeScanned(object sender, BarcodeScannedEventArgs args) { if (args.Barcode != string.Empty) { if (this.Visible && !this.CanFocus) { // modal child windows are open return; } using (MuhasebeEntities m_Context = new MuhasebeEntities()) { string m_Barcode = args.Barcode; var m_Item = m_Context.Items.Where(q => q.Inventory.OwnerID == Program.User.WorksAtID && q.Product.Barcode == m_Barcode).FirstOrDefault(); string m_Mode = this.BarcodeScannerMode_Combo.SelectedItem.ToString(); switch (m_Mode) { case "Satış": { if (m_Item == null) { this.Invoke((MethodInvoker) delegate() { Add_Item_Pop m_Pop = new Add_Item_Pop(m_Barcode); m_Pop.ShowDialog(); }); } else { if (!this.MdiChildren.Any(q => q is Manage_Sales_Mdi)) { this.BeginInvoke((MethodInvoker)(delegate() { Manage_Sales_Mdi m_Mdi = new Manage_Sales_Mdi(); m_Mdi.MdiParent = this; m_Mdi.WindowState = FormWindowState.Maximized; m_Mdi.Show(); m_Mdi.Shown += (s, a) => { InvoiceNode m_Node = new InvoiceNode(m_Item); m_Node.Amount = 1; m_Node.FinalPrice = m_Node.BasePrice * m_Node.Amount; m_Mdi.Append(m_Node); }; })); } else { Form m_Existing = this.MdiChildren.Where(q => q is Manage_Sales_Mdi).FirstOrDefault(); if (m_Existing != null) { Manage_Sales_Mdi m_Mdi = m_Existing as Manage_Sales_Mdi; m_Mdi.BeginInvoke((MethodInvoker) delegate() { InvoiceNode m_Node = new InvoiceNode(m_Item); m_Node.Amount = 1; m_Node.FinalPrice = m_Node.BasePrice * m_Node.Amount; m_Mdi.Append(m_Node); }); } } } break; } case "Ürün Düzenleme": { if (m_Item == null) { this.Invoke((MethodInvoker) delegate() { Add_Item_Pop m_Pop = new Add_Item_Pop(m_Barcode); m_Pop.ShowDialog(); }); } else { this.Invoke((MethodInvoker) delegate() { Edit_Item_Pop m_Pop = new Edit_Item_Pop(); m_Pop.Item = m_Item; m_Pop.ShowDialog(); }); } break; } } } } }