Пример #1
0
        private void bntProcess_Click(object sender, EventArgs e)
        {
            // Disable button, to avoid repeat pressing.
            this.btnCloseBooks.Enabled = false;
            this.bntProcess.Enabled = false;
            Vectra.DataSet2TableAdapters.configurationTableAdapter da = new Vectra.DataSet2TableAdapters.configurationTableAdapter();
            da.UpdateStatementDate(getFridaysDate().ToString("dd-MMM-yyyy"));
            da.Update(this.dataSet2);

            //-- Backup before updating
            logProgress("Daily backup");
            BackupSimple.doBackup(1);  // The 1 for daily

            try
            {
                logProgress("Processing Transactions");
                doWeeklyUpdate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
            }

            logProgress("Prepare Statements");
            using (Form f = new StatementReportForm())
            {
                f.WindowState = FormWindowState.Minimized;
                f.Show();
            }

            logProgress("Prepare Aged-Trial-Balance");
            using (Form f = new ATBReportForm())
            {
                f.WindowState = FormWindowState.Minimized;
                f.Show();
            }

            logProgress("Prepare Product Sales Details");
            using (Form f = new SalesProdReportForm())
            {
                f.WindowState = FormWindowState.Minimized;
                f.Show();
            }

            logProgress("Prepare Sales Summary");
            using (Form f = new SalesSummaryReportForm())
            {
                f.WindowState = FormWindowState.Minimized;
                f.Show();
            }

            logProgress("Prepare Receipts And Adjustments");
            using (Form f = new ReceiptAndAdjReportForm())
            {
                f.WindowState = FormWindowState.Minimized;
                f.Show();
            }

            logProgress("Prepare Customer Transaction");
            using (Form f = new CustomerTransactionReportForm())
            {
                f.WindowState = FormWindowState.Minimized;
                f.Show();
            }

            if (btnCloseBooks.Checked) // This closing the books.
            {
                logProgress("Reset Accounting Period");
                resetAccountingPeriod();

                sqLiteConnection1.Open();
                SQLiteCommand cmd = new SQLiteCommand();
                cmd.Connection = sqLiteConnection1;

                cmd.CommandText = "update invoice_header set invoice_locked = 1 where invoice_locked = 0";
                cmd.ExecuteNonQuery();

                cmd.CommandText = "update invoice_items set current_flag = '0' where current_flag = 1";
                cmd.ExecuteNonQuery();
                sqLiteConnection1.Close();
            }

            logProgress("Weekly backup");
            BackupSimple.doBackup(2);  // The 2 for Weekly

            logProgress("Finished.");
        }
Пример #2
0
        private void iNVOICE_HEADERBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            DataView dvn = new DataView(dataSet2.invoice_items);
            foreach (DataRowView r in dvn)
            {
                if (r.Row["prod_id"].ToString().Length < 2)
                {
                    r.Row.Delete();
                }
            }

            doTotal();

            this.invoice_unpaidTextBox.Text = this.totalTextBox.Text;
            this.Validate();

            ((DataRowView)iNVOICE_HEADERBindingSource.Current).Row["invoice_date"] =
                Convert.ToDateTime(((DataRowView)iNVOICE_HEADERBindingSource.Current).Row["invoice_date"]).ToString("dd/MM/yyyy");

            ((DataRowView)iNVOICE_HEADERBindingSource.Current).Row["sort_date"] =
                Convert.ToDateTime(((DataRowView)iNVOICE_HEADERBindingSource.Current).Row["invoice_date"]).ToString("yyyyMMdd");
            this.Validate();

            this.iNVOICE_HEADERBindingSource.EndEdit();
            this.invoice_itemsBindingSource.EndEdit();

            this.tableAdapterManager.UpdateAll(this.dataSet2);

            Vectra.DataSet2TableAdapters.configurationTableAdapter da = new Vectra.DataSet2TableAdapters.configurationTableAdapter();
            string acnt_period = da.getCurrentAcntPeriod().ToString();

            DataRowView dv = (DataRowView)this.iNVOICE_HEADERBindingSource.Current;

            string cmd = @"update customer_trans set t_amount = {0}, t_unpaid = {0}, t_week_id = '{4}', t_src_dckt_id = '{5}', t_date = '{6}' where t_type = '{1}' and t_cust_id = {2} and t_src_id = {3}";

            this.sqLiteConnection1.ConnectionString = myConfig.connstr;

            this.sqLiteConnection1.Open();
            this.sqLiteCommand1.CommandText =
                String.Format(cmd, dv.Row["invoice_amount"].ToString(), "Invoice", dv.Row["cust_id"], dv.Row["invoice_number"], acnt_period.ToString(), dv.Row["docket_number"].ToString(), dv.Row["invoice_date"].ToString());
            this.sqLiteCommand1.ExecuteNonQuery();
            this.sqLiteConnection1.Close();

            foreach (DataRowView r in dvn)
            {
                if (r.Row["prod_id"].ToString().Length < 2)
                {
                    r.Row.Delete();
                }
            }

            Close(); //close the form
        }
Пример #3
0
 private string getAcntPeriod()
 {
     Vectra.DataSet2TableAdapters.configurationTableAdapter da = new Vectra.DataSet2TableAdapters.configurationTableAdapter();
     return da.getCurrentAcntPeriod().ToString();
 }