Example #1
0
        private void StockUpdate(String PaymentType)
        {
            Stock         stock = new Stock();
            int           Current_Invoice_No    = 0;
            decimal       Current_Stock_Balance = 0.0m;
            SqlDataReader sdr = stock.GetMaxInvoiceNo();

            try
            {
                sdr.Read();
                Current_Invoice_No = sdr.GetInt32(0);
                sdr.Close();
            }
            catch { }

            int y = 0;
            int x = 0;
            int z = 0;

            int Invoce_No = Current_Invoice_No + 1;

            InvoiceNumber = Invoce_No.ToString();

            for (int i = 0; i < dataGridViewAll.Rows.Count; ++i)
            {
                decimal       sum             = Convert.ToDecimal(dataGridViewAll.Rows[i].Cells[7].Value);
                decimal       netdiscountline = (Convert.ToDecimal(dataGridViewAll.Rows[i].Cells[5].Value) * Convert.ToDecimal(dataGridViewAll.Rows[i].Cells[6].Value));
                decimal       sumoriginal     = (Convert.ToDecimal(dataGridViewAll.Rows[i].Cells[3].Value) * Convert.ToDecimal(dataGridViewAll.Rows[i].Cells[6].Value));
                SqlDataReader sdr1            = stock.GetStockBalance(Convert.ToInt32(dataGridViewAll.Rows[i].Cells[8].Value));
                try
                {
                    sdr1.Read();
                    Current_Stock_Balance = sdr1.GetDecimal(0);
                    sdr1.Close();
                    decimal Quantity = Convert.ToDecimal(dataGridViewAll.Rows[i].Cells[6].Value);
                    x = stock.InsertTransaction(Invoce_No, Convert.ToInt32(dataGridViewAll.Rows[i].Cells[8].Value), Quantity, "Customer_Invoice", 0, sumoriginal, netdiscountline, sum, Current_Stock_Balance, (Current_Stock_Balance - Quantity), Properties.Settings.Default.username, DateTime.Parse("1900-01-01"), "0");
                    if (x > 0)
                    {
                        y = stock.UpdateStockBalance(Convert.ToInt32(dataGridViewAll.Rows[i].Cells[8].Value), Quantity * -1);
                    }
                }
                catch { }
            }
            z = stock.InsertIvoice(Invoce_No, decimal.Parse(textBoxTotal.Text), decimal.Parse(textBoxNetDiscount.Text), decimal.Parse(textBoxtTlLineDiscount.Text), 0.0m, DateTime.Now, decimal.Parse(textBoxPaidAmount.Text), decimal.Parse(textBoxVoucherAmount.Text), decimal.Parse(textBoxBalanceAmount.Text));

            TotalAmount        = textBoxTotal.Text;
            DiscountAmount     = textBoxNetDiscount.Text;
            LineDiscountAmount = textBoxtTlLineDiscount.Text;
            DateTimeInvoice    = DateTime.Now.ToString();
            PaidAmount         = textBoxPaidAmount.Text;
            Balance            = textBoxBalanceAmount.Text;

            if (z > 0)
            {
                Voucher voucher = new Voucher();
                for (int i = 0; i < dataGridViewVoucher.Rows.Count; ++i)
                {
                    voucher.updateVoucher(Convert.ToInt32(dataGridViewVoucher.Rows[i].Cells[0].Value), Invoce_No);
                }
            }
            if (x > 0 && y > 0 && z > 0)
            {
                BillPrint bp = new BillPrint();
                bp.Show();

                //MessageBox.Show(" Successfully Added");
                dataGridViewAll.Rows.Clear();;
                textBoxQuantity.Clear();
                dataGridViewAll.Text = "";
                textBoxSelling.Clear();
                comboBoxCatID.Text = "";
                textBoxTotal.Clear();
                textBoxNetDiscountP.Clear();
                textBoxNetDiscount.Clear();
                textBoxtTlLineDiscountP.Clear();
                textBoxtTlLineDiscount.Clear();
                textBoxDueAmount.Clear();
                textBoxInvoice.Clear();
                textBoxPaidAmount.Clear();
                textBoxBalanceAmount.Clear();
                textBoxVoucherAmount.Clear();
                textBoxBarCode.Clear();
                textBoxVoucherNo.Clear();
                dataGridViewVoucher.Rows.Clear();
                if (labelVoucherVisible.Text != "1")
                {
                    button21_Click(null, null);
                }
            }
        }
Example #2
0
        public void sendPrintDetails()
        {
            string time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            try
            {
                if (pay_methd_lbl.Text != ".......................")
                {
                    string       insertquery = "INSERT INTO sales(inv_id,numberOfItems,pay_method,total,payment,balance) VALUES (@inv_id,@numberOfItems,@pay_method,@total,@payment,@balance)";
                    MySqlCommand cmd         = new MySqlCommand(insertquery, conn);

                    cmd.Parameters.AddWithValue("@inv_id", invoceno_lbl.Text);
                    cmd.Parameters.AddWithValue("@numberOfItems", itemQty_lbl.Text);
                    cmd.Parameters.AddWithValue("@pay_method", pay_methd_lbl.Text);
                    cmd.Parameters.AddWithValue("@total", total_lbl.Text);
                    cmd.Parameters.AddWithValue("@payment", payment_lbl.Text);
                    cmd.Parameters.AddWithValue("@balance", balance_lbl.Text);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Bill is processing...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    conn.Close();

                    BillPrint pr = new BillPrint();
                    pr.name_lblb.Text   = "Company Name" + "\n" + "Address Line 1" + "\n" + "Address Line 2" + "\n" + "Phone Number";
                    pr.invo_no_lbl.Text = "Invoice No : " + invoceno_lbl.Text;

                    //make line,
                    pr.AddNewLabel("", 0, 0, 90, pr.A = pr.A + 1).TextAlign = ContentAlignment.MiddleCenter;
                    pr.AddNewLabel("____________________________________", 0, 316, 90, pr.B = pr.B + 1).TextAlign = ContentAlignment.MiddleCenter;// Anchor = (AnchorStyles.Left & AnchorStyles.Right);
                    pr.AddNewLabel("", 0, 0, 90, pr.C = pr.C + 1).TextAlign = ContentAlignment.MiddleCenter;

                    /////string text, int left, int width, int top, int x

                    pr.AddNewLabel("Item", 8, 90, pr.A * 20, pr.A    = pr.A + 1).TextAlign = ContentAlignment.MiddleLeft;
                    pr.AddNewLabel("P x Q", 110, 90, pr.B * 20, pr.B = pr.B + 1).TextAlign = ContentAlignment.MiddleCenter;
                    pr.AddNewLabel("Rs.", 210, 90, pr.C * 20, pr.C   = pr.C + 1).TextAlign = ContentAlignment.MiddleRight;

                    //make line,
                    pr.AddNewLabel("", 0, 0, pr.A * 20, pr.A = pr.A + 1).TextAlign = ContentAlignment.MiddleCenter;
                    pr.AddNewLabel("____________________________________", 0, 316, pr.B * 20, pr.B = pr.B + 1).TextAlign = ContentAlignment.MiddleCenter;// Anchor = (AnchorStyles.Left & AnchorStyles.Right);
                    pr.AddNewLabel("", 0, 0, pr.C * 20, pr.C = pr.C + 1).TextAlign = ContentAlignment.MiddleCenter;

                    for (int i = 0; i < sales_gride.RowCount; i++)
                    {
                        pr.AddNewLabel(sales_gride.Rows[i].Cells[3].Value.ToString(), 8, 90, pr.A * 20, pr.A = pr.A + 1).TextAlign = ContentAlignment.MiddleLeft;
                        pr.AddNewLabel(sales_gride.Rows[i].Cells[4].Value.ToString() + " x " + sales_gride.Rows[i].Cells[5].Value.ToString(), 110, 90, pr.B * 20, pr.B = pr.B + 1).TextAlign = ContentAlignment.MiddleCenter;
                        pr.AddNewLabel(sales_gride.Rows[i].Cells[6].Value.ToString(), 210, 90, pr.C * 20, pr.C = pr.C + 1).TextAlign = ContentAlignment.MiddleRight;
                    }

                    //for space

                    /*pr.AddNewLabel("", 8);
                     * pr.AddNewLabel2("", 100, 120);
                     * pr.AddNewLabel1("", 200, 120);
                     */

                    //make line,
                    pr.AddNewLabel("", 0, 0, pr.A * 20, pr.A = pr.A + 1).TextAlign = ContentAlignment.MiddleCenter;
                    pr.AddNewLabel("____________________________________", 0, 316, pr.B * 20, pr.B = pr.B + 1).TextAlign = ContentAlignment.MiddleCenter;// Anchor = (AnchorStyles.Left & AnchorStyles.Right);
                    pr.AddNewLabel("", 0, 0, pr.C * 20, pr.C = pr.C + 1).TextAlign = ContentAlignment.MiddleCenter;

                    /////string text, int left, int width, int top, int x
                    //set name
                    pr.AddNewLabel("No of Items", 8, 90, pr.A * 20, pr.A = pr.A + 1).TextAlign = ContentAlignment.MiddleLeft;
                    pr.AddNewLabel("Pay Method", 8, 90, pr.A * 20, pr.A  = pr.A + 1).TextAlign = ContentAlignment.MiddleLeft;;
                    pr.AddNewLabel("Total", 8, 90, pr.A * 20, pr.A       = pr.A + 1).TextAlign = ContentAlignment.MiddleLeft;;
                    pr.AddNewLabel("Payment", 8, 90, pr.A * 20, pr.A     = pr.A + 1).TextAlign = ContentAlignment.MiddleLeft;;
                    pr.AddNewLabel("Balance", 8, 90, pr.A * 20, pr.A     = pr.A + 1).TextAlign = ContentAlignment.MiddleLeft;;

                    //set value
                    pr.AddNewLabel(itemQty_lbl.Text, 210, 90, pr.B * 20, pr.B   = pr.B + 1).TextAlign = ContentAlignment.MiddleRight;
                    pr.AddNewLabel(pay_methd_lbl.Text, 210, 90, pr.B * 20, pr.B = pr.B + 1).TextAlign = ContentAlignment.MiddleRight;
                    pr.AddNewLabel(total_lbl.Text, 210, 90, pr.B * 20, pr.B     = pr.B + 1).TextAlign = ContentAlignment.MiddleRight;
                    pr.AddNewLabel(payment_lbl.Text, 210, 90, pr.B * 20, pr.B   = pr.B + 1).TextAlign = ContentAlignment.MiddleRight;
                    pr.AddNewLabel(balance_lbl.Text, 210, 90, pr.B * 20, pr.B   = pr.B + 1).TextAlign = ContentAlignment.MiddleRight;

                    //set text
                    pr.AddNewLabel("===========++++++++++++++==========", 0, 316, pr.A * 20, pr.A = pr.A + 1).TextAlign = ContentAlignment.MiddleCenter;
                    pr.AddNewLabel(time, 0, 316, pr.A * 20, pr.A = pr.A + 1).TextAlign = ContentAlignment.MiddleCenter;
                    pr.AddNewLabel("Thank You Come Again...", 0, 316, pr.A * 20, pr.A = pr.A + 1).TextAlign = ContentAlignment.MiddleCenter;

                    //set space
                    pr.panel1.Height = pr.panel1.Height + 40;
                    pr.Height        = pr.panel1.Height + 20;

                    // show print form
                    pr.Show();
                    pr.printDocument1.Print();
                    autoID();
                    allclear();
                }
                else
                {
                    MessageBox.Show("Please select payment method...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            conn.Close();
        }