private void btnExport_Click(object sender, EventArgs e)
        {
            if (dgvReload.Rows.Count == 0)
            {
                MessageBox.Show("Nothing to export.", "Export To Excel", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            clsExportToExcel export  = new clsExportToExcel();
            SaveFileDialog   savedlg = new SaveFileDialog();

            savedlg.Filter           = "Excel File (*.xls)|*.xls";
            savedlg.InitialDirectory = Application.StartupPath;
            if (savedlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string columns = "";
                foreach (DataGridViewColumn col in dgvReload.Columns)
                {
                    columns += col.HeaderText + (col != dgvReload.Columns[dgvReload.Columns.Count - 1] ? "\t" : "");
                }
                List <string> lstValues = new List <string>();
                foreach (DataGridViewRow row in dgvReload.Rows)
                {
                    string val = "";
                    for (int ctr = 0; ctr < dgvReload.Columns.Count; ctr++)
                    {
                        val += row.Cells[ctr].Value.ToString() + (ctr != dgvReload.Columns.Count - 1 ? "\t" : "");
                    }
                    lstValues.Add(val);
                }
                export.SaveToExcel(savedlg.FileName, columns, lstValues);
            }
        }
Beispiel #2
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (dgvReceipt.Rows.Count == 0)
            {
                MessageBox.Show("Nothing to export.", "Export To Excel", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            clsExportToExcel export  = new clsExportToExcel();
            SaveFileDialog   savedlg = new SaveFileDialog();

            savedlg.Filter           = "Excel File (*.xls)|*.xls";
            savedlg.InitialDirectory = Application.StartupPath;
            if (savedlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string columns = "";
                foreach (DataGridViewColumn col in dgvReceipt.Columns)
                {
                    columns += col.HeaderText + (col != dgvReceipt.Columns[dgvReceipt.Columns.Count - 1] ? "\t" : "");
                }
                List <string> lstValues = new List <string>();
                frmProgress   progress  = new frmProgress(dgvReceipt.Rows.Count);
                progress.Caption       = "Loading Data";
                progress.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                progress.Show();
                int ctr2 = 0;

                foreach (DataGridViewRow row in dgvReceipt.Rows)
                {
                    string val = "HEADER1";
                    for (int ctr = 0; ctr < dgvReceipt.Columns.Count; ctr++)
                    {
                        val += row.Cells[ctr].Value.ToString() + (ctr != dgvReceipt.Columns.Count - 1 ? "\t" : "");
                    }
                    lstValues.Add(val);
                    Receipt r = new Receipt(Convert.ToInt32(row.Cells[1].Value));
                    if (r != null)
                    {
                        val = "BARCODE\tDESCRIPTION\tQTY\tAMOUNT\tTOTAL\tHEADER2";
                        lstValues.Add(val);

                        foreach (KeyValuePair <string, clsPurchasedItem> p in r.PurchasedItems)
                        {
                            val = string.Format("[{0}]\t{1}\t{2}\t{3}\t{4}\t", p.Value.BarCode, p.Value.Description, p.Value.Qty, p.Value.Amount - p.Value.Discount, p.Value.Qty * (p.Value.Amount - p.Value.Discount));
                            lstValues.Add(val);
                        }
                        //lstValues.Add("\t");
                    }
                    progress.Val = ++ctr2;
                }
                progress.Close();
                export.SaveToExcelWithSummary(savedlg.FileName, columns, lstValues, "Total Sales\tAccounts Receivable\tNet Profit", string.Format("{0}\t{1}\t{2}", TotalIncome - TotalDiscounts, TotalAccountsReceivable, NetProfit));
            }
        }
Beispiel #3
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            OpenFileDialog opendlg = new OpenFileDialog();

            opendlg.Filter           = "Excel File (*.xls)|*.xls";
            opendlg.InitialDirectory = Application.StartupPath;
            if (opendlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                clsExportToExcel import = new clsExportToExcel();
                if (import.UploadSubD(opendlg.FileName, m_LoadAccount.LoadId))
                {
                    ReloadSubD();
                }
            }
        }
Beispiel #4
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (dgvExpenses.Rows.Count == 0)
            {
                MessageBox.Show("Nothing to export.", "Export To Excel", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            clsExportToExcel export  = new clsExportToExcel();
            SaveFileDialog   savedlg = new SaveFileDialog();

            savedlg.Filter           = "Excel File (*.xls)|*.xls";
            savedlg.InitialDirectory = Application.StartupPath;
            if (savedlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string columns = "";
                foreach (DataGridViewColumn col in dgvExpenses.Columns)
                {
                    columns += col.HeaderText + (col != dgvExpenses.Columns[dgvExpenses.Columns.Count - 1]?"\t":"");
                }
                List <string> lstValues = new List <string>();
                frmProgress   progress  = new frmProgress(dgvExpenses.Rows.Count);
                progress.Caption       = "Loading Data";
                progress.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                progress.Show();
                int ctr2 = 0;

                foreach (DataGridViewRow row in dgvExpenses.Rows)
                {
                    string val = "";
                    for (int ctr = 0; ctr < dgvExpenses.Columns.Count; ctr++)
                    {
                        val += row.Cells[ctr].Value.ToString() + (ctr != dgvExpenses.Columns.Count - 1?"\t":"");
                    }
                    lstValues.Add(val);
                    progress.Val = ++ctr2;
                }
                progress.Close();
                export.SaveToExcelWithSummary(savedlg.FileName, columns, lstValues, "Total Expenses", string.Format("{0}", TotalExpenses));
            }
        }
Beispiel #5
0
 private bool UpdateInventory()
 {
     try
     {
         if (m_ListProdItems != null)
         {
             clsExportToExcel import  = new clsExportToExcel();
             OpenFileDialog   opendlg = new OpenFileDialog();
             opendlg.Filter           = "Excel File (*.xls)|*.xls";
             opendlg.InitialDirectory = Application.StartupPath;
             if (opendlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 import.UpdateInventory(opendlg.FileName, m_ListProdItems, m_username);
                 SearchPurchases();
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Update Inventory", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     return(false);
 }
Beispiel #6
0
        private void btnGenStatement_Click(object sender, EventArgs e)
        {
            if (dgvAccounts.Rows.Count == 0)
            {
                MessageBox.Show("Nothing to export.", "Export To Excel", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            clsExportToExcel export  = new clsExportToExcel();
            SaveFileDialog   savedlg = new SaveFileDialog();

            savedlg.Filter           = "Excel File (*.xls)|*.xls";
            savedlg.InitialDirectory = Application.StartupPath;
            Dictionary <DateTime, clsAccountStatement> tmpDicStatement = new Dictionary <DateTime, clsAccountStatement>();
            List <clsAccountStatement> lstStatement = new List <clsAccountStatement>();

            if (savedlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                foreach (clsChargedTransaction charge in m_Charges)
                {
                    clsAccountStatement ac = new clsAccountStatement();
                    ac.TransDate   = charge.Timestamp.ToString("yyyy-MM-dd HH:mm:ss");
                    ac.ORInfo      = new Receipt(charge.ORNum);
                    ac.Description = string.Format("OR#{0:00000} Amount Due:{1:00} Amount Paid:{2:0.00}", charge.ORNum, ac.ORInfo.TotalDiscountedAmount, ac.ORInfo.PaidAmount);
                    ac.Debit       = charge.ChargedAmount;
                    ac.Credit      = 0;
                    ac.Balance     = 0;
                    tmpDicStatement.Add(Convert.ToDateTime(ac.TransDate), ac);
                }
                foreach (clsPaymentInfo pay in m_Payments)
                {
                    clsAccountStatement ac = new clsAccountStatement();
                    bool add = true;
                    while (tmpDicStatement.ContainsKey(pay.Timestamp))
                    {
                        pay.Timestamp = pay.Timestamp.AddSeconds(1);
                    }

                    ac.TransDate   = pay.Timestamp.ToString("yyyy-MM-dd HH:mm:ss");
                    ac.Description = string.Format("{0}", pay.Remarks);
                    ac.Debit       = 0;
                    ac.Credit      = pay.AmountPaid;
                    ac.Balance     = 0;
                    ac.ORInfo      = null;

                    if (add)
                    {
                        tmpDicStatement.Add(Convert.ToDateTime(ac.TransDate), ac);
                    }
                }
                List <DateTime> lstKeys = tmpDicStatement.Keys.OrderBy(x => x).ToList();
                double          balance = 0;
                foreach (DateTime dt in lstKeys)
                {
                    if (!tmpDicStatement[dt].Description.Contains("Interest"))
                    {
                        tmpDicStatement[dt].Balance = tmpDicStatement[dt].Credit - tmpDicStatement[dt].Debit + balance;
                    }
                    else
                    {
                        tmpDicStatement[dt].Balance = balance;
                    }
                    balance = tmpDicStatement[dt].Balance;
                    lstStatement.Add(tmpDicStatement[dt]);
                    if (tmpDicStatement[dt].ORInfo != null)
                    {
                        foreach (KeyValuePair <string, clsPurchasedItem> p in tmpDicStatement[dt].ORInfo.PurchasedItems)
                        {
                            clsAccountStatement ac = new clsAccountStatement();
                            ac.TransDate   = "";
                            ac.Description = string.Format("{1} x {0} : {2}", p.Value.Description, p.Value.Qty, (p.Value.Amount * p.Value.Qty) - (p.Value.Discount * p.Value.Qty));
                            ac.Debit       = 0;
                            ac.Credit      = 0;
                            ac.ORInfo      = null;
                            ac.Balance     = balance;
                            lstStatement.Add(ac);
                        }
                    }
                }

                export.SaveStatementToExcel(savedlg.FileName, dgvAccounts.SelectedRows[0].Cells[1].Value.ToString(), Convert.ToDouble(dgvAccounts.SelectedRows[0].Cells[2].Value), Convert.ToDouble(dgvAccounts.SelectedRows[0].Cells[3].Value), Convert.ToDouble(dgvAccounts.SelectedRows[0].Cells[4].Value), lstStatement);
            }
        }