Beispiel #1
0
        private void LoadGridDataToItemsTable(string receiptid)
        {
            SqlDriver driver = new SqlDriver();

            string[,] items = driver.GetItems(receiptid);
            dataGridItems.Rows.Clear();

            for (int index = 0; index < items.GetLength(0); index++)
            {
                dataGridItems.Rows.Add();
                dataGridItems.Rows[index].Cells[0].Value = items[index, 0];
                dataGridItems.Rows[index].Cells[1].Value = items[index, 1];
                dataGridItems.Rows[index].Cells[2].Value = items[index, 7];
                dataGridItems.Rows[index].Cells[3].Value = items[index, 2];
                dataGridItems.Rows[index].Cells[4].Value = items[index, 3];
                dataGridItems.Rows[index].Cells[5].Value = items[index, 4];
                dataGridItems.Rows[index].Cells[6].Value = items[index, 5];
                dataGridItems.Rows[index].Cells[7].Value = items[index, 6];
            }
        }
Beispiel #2
0
        private void LoadGridData()
        {
            SqlDriver driver = new SqlDriver();

            string[,] items = driver.GetAllReceipts();
            dataGridView.Rows.Clear();

            int    receiptsCount = 0;
            double priceSum      = 0;

            vyberyAmount        = 0;
            vkladyAmount        = 0;
            invoicesAmount      = 0;
            sumTaxBaseBasic     = 0;
            sumTaxBaseReduced   = 0;
            sumBasicVatAmount   = 0;
            sumReducedVatAmount = 0;
            sumTaxFreeAmount    = 0;
            sumPaycard          = 0;
            sumPaycash          = 0;
            sumPaystr           = 0;
            sumPayvmp           = 0;
            sumPaycardInvoice   = 0;
            sumPaycashInvoice   = 0;

            for (int index = 0; index < items.GetLength(0); index++)
            {
                dataGridView.Rows.Add();
                dataGridView.Rows[index].Cells[0].Value  = items[index, 0];
                dataGridView.Rows[index].Cells[1].Value  = items[index, 5];
                dataGridView.Rows[index].Cells[2].Value  = items[index, 1];
                dataGridView.Rows[index].Cells[3].Value  = items[index, 2];
                dataGridView.Rows[index].Cells[4].Value  = items[index, 3];
                dataGridView.Rows[index].Cells[5].Value  = items[index, 4];
                dataGridView.Rows[index].Cells[6].Value  = items[index, 6];
                dataGridView.Rows[index].Cells[7].Value  = items[index, 8];
                dataGridView.Rows[index].Cells[8].Value  = items[index, 7];
                dataGridView.Rows[index].Cells[9].Value  = items[index, 9];
                dataGridView.Rows[index].Cells[10].Value = items[index, 10];
                dataGridView.Rows[index].Cells[11].Value = items[index, 11];
                dataGridView.Rows[index].Cells[12].Value = items[index, 13];
                dataGridView.Rows[index].Cells[13].Value = items[index, 15];
                dataGridView.Rows[index].Cells[14].Value = items[index, 14];
                dataGridView.Rows[index].Cells[15].Value = items[index, 16];
                dataGridView.Rows[index].Cells[16].Value = items[index, 17];
                dataGridView.Rows[index].Cells[17].Value = items[index, 12];

                if (items[index, 6].Equals("ONLINE") || items[index, 6].Equals("OFFLINE"))
                {
                    if (items[index, 11].Equals("UF"))
                    {
                        invoicesAmount    += double.Parse(items[index, 2], CultureInfo.InvariantCulture);
                        sumPaycardInvoice += items[index, 7] == String.Empty ? 0 : double.Parse(items[index, 7], CultureInfo.InvariantCulture);
                        sumPaycashInvoice += items[index, 8] == String.Empty ? 0 : double.Parse(items[index, 8], CultureInfo.InvariantCulture);
                    }
                    if (items[index, 11].Equals("VY"))
                    {
                        vyberyAmount += double.Parse(items[index, 2], CultureInfo.InvariantCulture);
                    }
                    if (items[index, 11].Equals("VK"))
                    {
                        vkladyAmount += double.Parse(items[index, 2], CultureInfo.InvariantCulture);
                    }
                    if (items[index, 11].Equals("PD"))
                    {
                        priceSum   += double.Parse(items[index, 2], CultureInfo.InvariantCulture);
                        sumPaycard += items[index, 7] == String.Empty ? 0 : double.Parse(items[index, 7], CultureInfo.InvariantCulture);
                        sumPaycash += items[index, 8] == String.Empty ? 0 : double.Parse(items[index, 8], CultureInfo.InvariantCulture);
                        sumPaystr  += items[index, 9] == String.Empty ? 0 : double.Parse(items[index, 9], CultureInfo.InvariantCulture);
                        sumPayvmp  += items[index, 10] == String.Empty ? 0 : double.Parse(items[index, 10], CultureInfo.InvariantCulture);
                    }

                    receiptsCount++;

                    sumTaxBaseBasic     += items[index, 13] == String.Empty ? 0 : double.Parse(items[index, 13], CultureInfo.InvariantCulture);
                    sumTaxBaseReduced   += items[index, 14] == String.Empty ? 0 : double.Parse(items[index, 14], CultureInfo.InvariantCulture);
                    sumBasicVatAmount   += items[index, 15] == String.Empty ? 0 : double.Parse(items[index, 15], CultureInfo.InvariantCulture);
                    sumReducedVatAmount += items[index, 16] == String.Empty ? 0 : double.Parse(items[index, 16], CultureInfo.InvariantCulture);
                    sumTaxFreeAmount    += items[index, 17] == String.Empty ? 0 : double.Parse(items[index, 17], CultureInfo.InvariantCulture);
                }
            }

            if (dataGridView.Rows.Count > 0)
            {
                firstDate = dataGridView.Rows[0].Cells[1].Value.ToString();
                lastDate  = dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[1].Value.ToString();
            }
            else
            {
                var now = DateTime.Now;
                firstDate = now.ToString("dd.MM.yyyy HH.mm.ss");
                lastDate  = now.ToString("dd.MM.yyyy HH.mm.ss");
            }

            toolStripPD.Text   = receiptsCount.ToString();
            toolStripZisk.Text = priceSum.ToString() + " €";
            obratAmount        = priceSum;

            toolTaxBaseBasic.Text   = sumTaxBaseBasic.ToString("N2") + " €";
            toolVatBaseBasic.Text   = sumBasicVatAmount.ToString("N2") + " €";
            toolTaxBaseReduced.Text = sumTaxBaseReduced.ToString("N2") + " €";
            toolVarBaseReduced.Text = sumReducedVatAmount.ToString("N2") + " €";
            toolTaxFree.Text        = sumTaxFreeAmount.ToString("N2") + " €";
            toolPayCash.Text        = sumPaycash.ToString("N2") + " €";
            toolPayCard.Text        = sumPaycard.ToString("N2") + " €";
        }
Beispiel #3
0
        async public void CreateDatabase()
        {
            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                SqlDriver sqlDriver = new SqlDriver();
                sqlDriver.CreateDatabase();

                stopProcess     = false;
                panel.Visible   = true;
                textBoxLog.Text = "Nová databáza vytvorená: /n " + Program.DB_PATH;
                string path = folderBrowserDialog.SelectedPath;

                string[] files      = Directory.GetFiles(path, "*sent.xml");
                double   totalFiles = files.Length;
                double   filesDone  = 0;

                labelDone.Text           = "0";
                labelLeft.Text           = "0";
                labelPer.Text            = "0%";
                progressBarProcess.Value = 0;

                labelAll.Text = totalFiles.ToString();

                foreach (string file in Directory.EnumerateFiles(path, "*sent.xml"))
                {
                    if (stopProcess)
                    {
                        break;
                    }

                    if (file.Contains("sent"))
                    {
                        await Task.Delay(10);

                        filesDone++;
                        labelDone.Text           = filesDone.ToString();
                        labelLeft.Text           = (totalFiles - filesDone).ToString();
                        labelPer.Text            = ((filesDone / totalFiles) * 100).ToString("N2") + "%";
                        progressBarProcess.Value = Int32.Parse(Math.Ceiling((filesDone / totalFiles) * 100).ToString());
                        Console.WriteLine(file);
                        textBoxLog.AppendText("\nSpracovanie: " + file);
                        textBoxLog.ScrollToCaret();
                        string     xml        = File.ReadAllText(file);
                        XmlHandler xmlHandler = new XmlHandler(xml);
                        if (xmlHandler.ReadXML())
                        {
                            textBoxLog.SelectionColor = Color.Green;
                            textBoxLog.AppendText("\nOK");
                            textBoxLog.SelectionColor = Color.Black;
                        }
                        else
                        {
                            textBoxLog.SelectionColor = Color.Red;
                            textBoxLog.AppendText("\nERROR:");
                            textBoxLog.SelectionColor = Color.Black;
                        }

                        Dictionary <string, string> data = new Dictionary <string, string>();
                        data.Add("uid", XmlHandler.OKPValue);
                        data.Add("date", XmlHandler.DateValue);
                        data.Add("amount", XmlHandler.AmountValue);
                        data.Add("receiptnumber", String.Empty);
                        data.Add("intreceiptnumber", XmlHandler.ReceiptNumberValue);
                        data.Add("mod", "ONLINE");
                        data.Add("paycard", XmlHandler.payment[1]);
                        data.Add("paycash", XmlHandler.payment[0]);
                        data.Add("paystr", XmlHandler.payment[2]);
                        data.Add("payvmp", XmlHandler.payment[3]);
                        data.Add("xmldata", xml);
                        data.Add("receipttype", XmlHandler.ReceiptTypeValue);
                        data.Add("invoicenumber", XmlHandler.InvoiceNumberValue);
                        data.Add("taxbasebasic", XmlHandler.TaxBaseBasicValue);
                        data.Add("taxbasereduced", XmlHandler.TaxBaseReducedValue);
                        data.Add("basicvatamount", XmlHandler.BasicVatAmountValue);
                        data.Add("reducedvatamount", XmlHandler.ReducedVatAmountValue);
                        data.Add("taxfreeamount", XmlHandler.TaxFreeAmountValue);

                        SqlDriver driver = new SqlDriver();
                        string    lastid = driver.InsertReceipt(data);
                        driver.InsertReceiptItems(XmlHandler.items, lastid);
                    }
                }

                if (totalFiles == filesDone)
                {
                    textBoxLog.SelectionColor = Color.Green;
                    textBoxLog.AppendText("\nDOKONČENÉ");
                    textBoxLog.SelectionColor = Color.Black;
                    textBoxLog.ScrollToCaret();
                }

                LoadGridData();
                buttonOk.Enabled = true;
            }
        }