Example #1
0
        /*
         * New Transaction button functions end here
         */



        /*
         * Print button functionality starts here
         */
        private void button7_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Fill Paid");
            }
            else
            {
                if (customernid == null)
                {
                    MessageBox.Show("Please Fillup Customer Info");
                }
                else
                {
                    //Document doc = new Document(PageSize.A4.Rotate());
                    //string documentPath = @"C:\\Users\\ahmed\\Desktop\\PDF\\";
                    //string filename = 100000 + ".pdf";
                    //string documentFullPath = documentPath + filename;


                    //string invPath = "C:\\Users\\ahmed\\Desktop\\PDF\\";
                    //string path = invPath + 100000 + ".pdf";
                    //doc.Open();
                    //PdfPTable table = new PdfPTable(dataGridView1.Columns.Count);
                    //for (int j = 0; j < dataGridView1.Columns.Count; j++)
                    //{
                    //    table.AddCell(new Phrase(dataGridView1.Columns[j].HeaderText));
                    //}
                    //table.HeaderRows = 1;
                    //for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    //{
                    //    for (int j = 0; j < dataGridView1.Columns.Count; j++)
                    //    {
                    //        if (dataGridView1[j, i].Value != null)
                    //        {
                    //            table.AddCell(new Phrase(dataGridView1[j, i].Value.ToString()));
                    //        }
                    //    }
                    //}
                    //doc.Add(table);
                    //doc.Close();

                    uint num = new POSPresenter().generateInvoice(VatForm.vat, new POSPresenter().totalshopingAmount, date, time, Admin.Text, textBox1.Text, textBox2.Text);
                    LabelInvoice.Text = num.ToString();
                    new POSPresenter().newTransaction();

                    textBoxInvoiceTotalCost.Text  = null;
                    dataGridView1.DataSource      = null;
                    textBoxInvoiceTotalItems.Text = Convert.ToString(0);

                    customernid = null;
                    MessageBox.Show("Successfull");
                    textBox1.Text = "";
                    textBox2.Text = "";
                }
            }
        }
Example #2
0
        private void textQuantity_EnterKeyPressed(object sender, EventArgs e)
        {
            if (reference != null)
            {
                uint   originalQuantity = reference.Quantity;
                double VAT;
                uint   quantity;

                /*
                 * Unnecessary code starts here
                 */
                Console.WriteLine("Vat : " + mainFormReference.VAT.ToString());
                textinvoiceVAT.Text = VatForm.vat.ToString();

                /*
                 * Unnecessary code ends here
                 */

                Debug.Assert(reference != null);

                if (double.TryParse(textinvoiceVAT.Text, out VAT))
                {
                    if (uint.TryParse(textQuantity.Text, out quantity))
                    {
                        if (quantity <= originalQuantity)
                        {
                            POSPresenter pp = new POSPresenter();
                            textBoxInvoiceTotalCost.Text = Convert.ToString(pp.addItemToInvoice(reference.ProductCode, Convert.ToDouble(reference.Price),
                                                                                                Convert.ToUInt32(textQuantity.Text), Convert.ToDouble(textinvoiceVAT.Text)));
                            dataGridView1.AutoGenerateColumns = false;
                            dataGridView1.DataSource          = null;
                            var list = new BindingList <WCSA_Entity_Classes.Product>(pp.getInvoiceItemsList());
                            dataGridView1.DataSource      = list;
                            textBoxInvoiceTotalItems.Text = Convert.ToString(pp.getInvoiceItemsList().Count);

                            textPCode.Text        = null;
                            textUnitPrice.Text    = null;
                            text_P_Name.Text      = null;
                            textQuantity.Text     = null;
                            textUnitPrice.Enabled = true;
                            textPCode.Enabled     = true;
                            text_P_Name.Enabled   = true;
                            textTotalPrice.Text   = null;
                            textBarCode.Text      = null;

                            reference = null;
                        }
                        else
                        {
                            MessageBox.Show("Not enough items in stock");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter quantity");
                    }
                }
                else
                {
                    MessageBox.Show("Please input VAT");
                }
            }
            else
            {
                MessageBox.Show("Product Not found !");
            }
        }