/// <summary> /// this is the delete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DeleteButtonClicked(object sender, NewEventArgs e) { try { int li = e.LineItemID; RegisterLineItemControl RemoveCandidate = new RegisterLineItemControl(); foreach (RegisterLineItemControl item in flowPanel.Controls) { if (item.UserControlLineItemID == li) { RemoveCandidate = item; } } flowPanel.Controls.Remove(RemoveCandidate); // reindex the flow panel foreach (RegisterLineItemControl item in flowPanel.Controls) { if (item.UserControlLineItemID > li) { item.UserControlLineItemID--; } } TheSale.DeleteRow(e.LineItemID); this.LineItem--; } catch (Exception ex) { MessageBox.Show(string.Format("Exception at DeleteButtonClicked: {0}", ex)); } CalculateRegister(); FocusMe(); }
private void txtBarCodeScan_TextChanged(object sender, EventArgs e) { try { //call the barcode look up if (txtBarCodeScan.TextLength == 9) { int ScanID = 0; if (int.TryParse(txtBarCodeScan.Text.ToString(), out ScanID) == true) { ScanID = int.Parse(txtBarCodeScan.Text); SoldLineItem c = BarCodeScan(ScanID); if (c != null) { if (DuplicateCheck(c) == false) { TheSale.Add(c); RegisterLineItemControl u = new RegisterLineItemControl(); u.LoadControl(c); u.DeleteClick += new RegisterLineItemControl.ButtonClick(DeleteButtonClicked); //u.TextChange += new UserControl1.TextBoxChange(TextBoxChanged); u.quantityChange += new RegisterLineItemControl.QuantityChange(QuantityChanged); u.priceChange += new RegisterLineItemControl.PriceChange(PriceChanged); flowPanel.Controls.Add(u); CalculateRegister(); LineItem = LineItem + 1; } else { MessageBox.Show("Duplicate Scan", "DoubleTake POS", MessageBoxButtons.OK, MessageBoxIcon.Warning); } txtBarCodeScan.Text = string.Empty; FocusMe(); } else { MessageBox.Show("No Scan ID Found", "DoubleTake POS", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } } catch (Exception ex) { MessageBox.Show(string.Format("Exception at txtBarCodeScan_TextChanged: {0}", ex)); } }