示例#1
0
        private void Add1000ItemsBtn_Click(object sender, EventArgs e)
        {
            var types      = ItemTypeMgmt.SelectAll();
            var categories = ItemCategoryMgmt.SelectAll();
            var vendors    = VendorsMgmt.SelectAllVendors();

            if (types.Rows.Count == 0 || categories.Rows.Count == 0 | vendors.Rows.Count == 0)
            {
                GenerateItemsConfigs();

                types      = ItemTypeMgmt.SelectAll();
                categories = ItemCategoryMgmt.SelectAll();
                vendors    = VendorsMgmt.SelectAllVendors();
            }

            var cnt     = 2;
            var aRandom = new Random();

            while (cnt < NumberOfItems)
            {
                var aItem = new Items();
                aItem.Item_Barcode     = $"Test Item {cnt}";
                aItem.Item_Type        = int.Parse(types.Rows[cnt % NumberOfConfigs]["ID"].ToString());
                aItem.Item_Category    = int.Parse(categories.Rows[cnt % NumberOfConfigs]["ID"].ToString());
                aItem.Vendor           = int.Parse(vendors.Rows[cnt % NumberOfConfigs]["ID"].ToString());
                aItem.Item_Description = $"Test Item {cnt}";
                aItem.Item_Tax_Level   = (cnt % 6 != 0) ? cnt % 6 : 1;
                aItem.OnHandQty        = cnt;
                aItem.Render_Point     = 10;
                aItem.Sell_Price       = aRandom.Next(50, 300);
                aItem.PriceLevelID     = 1;
                aItem.Entry_Date       = "1/1/2009";
                aItem.Avg_Unit_Cost    = aItem.Sell_Price - 10;
                aItem.Avalable_Qty     = cnt;
                cnt++;

                if (!ItemsMgmt.AddItem(aItem))
                {
                    return;
                }
                if (cnt % 100 == 0)
                {
                    label1.Text = $"Adding Item {cnt}/{NumberOfItems} ... ({(cnt / NumberOfItems) * 100 })%";
                    Application.DoEvents();
                }
            }
        }
示例#2
0
        private void ListDCBtn_Click(object sender, EventArgs e)
        {
            int FilterVendorID = int.Parse(VendorNameComboBox.SelectedValue.ToString());

            aCurrencyTable      = CurrencyMgmt.SelectAll();
            aUsersTable         = UsersMgmt.SelectAllUsers();
            aAccountsTable      = AccountsMgmt.SelectAll();
            aPaymentMethodTable = PaymentMethodMgmt.SelectAll();
            aAccountsTable      = AccountsMgmt.SelectAll();
            aVendorTable        = VendorsMgmt.SelectAllVendors();

            DebitDGView.Rows.Clear();
            CreditDGView.Rows.Clear();

            int FilterTellerNameID = 0;

            if (TellerNameChkBox.Checked)
            {
                FilterTellerNameID = int.Parse(TellerNameComboBox.SelectedValue.ToString());
            }

            string FilterDateFrom = "";
            string FilterDateTo   = "";

            if (DateCheckBox.Checked)
            {
                FilterDateFrom = DateFrompicker.Value.ToShortDateString();
                FilterDateTo   = DateToPicker.Value.ToShortDateString();
            }

            bool FilterCheckedBills = CheckChkBox.Checked;
            bool FilterIsRevised    = RevisedChkBox.Checked;

            bool FilterUnCheckedBills = UnCheckedChkBox.Checked;
            bool FilterUnRevisedBills = UnRevisedChkBox.Checked;
            bool FilterBillCashCredit = CreditBillsChkBox.Checked;

            //LISTING BILLS
            aPurchaseVoucherTable      = PurchaseVoucherGeneralMgmt.SelectAllVouchers(FilterTellerNameID, FilterDateFrom, FilterDateTo, FilterCheckedBills, FilterIsRevised, FilterUnCheckedBills, FilterUnRevisedBills, FilterVendorID, FilterBillCashCredit);
            TotalITemsTxtBoxDebit.Text = aPurchaseVoucherTable.Rows.Count.ToString();

            TotalDebitPriceTxtBox.Text = "0";
            if (aPurchaseVoucherTable.Rows.Count > 0)
            {
                double TotalDebitPrice = 0;
                for (int i = 0; i < aPurchaseVoucherTable.Rows.Count; i++)
                {
                    TotalDebitPrice += double.Parse(aPurchaseVoucherTable.Rows[i]["TotalCost"].ToString());
                }
                TotalDebitPriceTxtBox.Text = TotalDebitPrice.ToString();
                RowNumDebit = 0;
                if (DebitDGView.Rows.Count < ItemsPerPageDebit)
                {
                    //TestingFor Paging
                    pagesnumberDebit = (int)aPurchaseVoucherTable.Rows.Count / ItemsPerPageDebit;
                    if ((double.Parse(aPurchaseVoucherTable.Rows.Count.ToString()) / ItemsPerPageDebit - int.Parse(aPurchaseVoucherTable.Rows.Count.ToString()) / ItemsPerPageDebit) > 0)
                    {
                        pagesnumberDebit++;
                    }
                    foreach (DataRow r in aPurchaseVoucherTable.Rows)
                    {
                        if (DebitDGView.Rows.Count < ItemsPerPageDebit)
                        {
                            DebitDGView.Rows.Add();
                            DebitDGView.Rows[RowNumDebit].Cells["VoucherNumber"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["VoucherNumber"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["Date"].Value          = aPurchaseVoucherTable.Rows[RowNumDebit]["Date"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["Time"].Value          = aPurchaseVoucherTable.Rows[RowNumDebit]["Time"].ToString();
                            for (int i = 0; i < aVendorTable.Rows.Count; i++)
                            {
                                if (int.Parse(aVendorTable.Rows[i]["ID"].ToString()) == int.Parse(aPurchaseVoucherTable.Rows[RowNumDebit]["VendorID"].ToString()))
                                {
                                    DebitDGView.Rows[RowNumDebit].Cells["Vendor"].Value = aVendorTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNumDebit]["TellerID"].ToString();
                                    break;
                                }
                            }
                            DebitDGView.Rows[RowNumDebit].Cells["TotalFreeITemsQty"].Value  = aPurchaseVoucherTable.Rows[RowNumDebit]["TotalFreeITemsQty"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["TotalTax"].Value           = aPurchaseVoucherTable.Rows[RowNumDebit]["TotalTax"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["Subtotal"].Value           = aPurchaseVoucherTable.Rows[RowNumDebit]["Subtotal"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["DiscountPerc"].Value       = aPurchaseVoucherTable.Rows[RowNumDebit]["DiscountPerc"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["TotalItemsDiscount"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["TotalItemsDiscount"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["TotalDiscount"].Value      = aPurchaseVoucherTable.Rows[RowNumDebit]["TotalDiscount"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["TotalCost"].Value          = aPurchaseVoucherTable.Rows[RowNumDebit]["TotalCost"].ToString();
                            for (int i = 0; i < aPaymentMethodTable.Rows.Count; i++)
                            {
                                if (int.Parse(aPaymentMethodTable.Rows[i]["ID"].ToString()) == int.Parse(aPurchaseVoucherTable.Rows[RowNumDebit]["PaymentMethodID"].ToString()))
                                {
                                    DebitDGView.Rows[RowNumDebit].Cells["PaymentMethod"].Value = aPaymentMethodTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNumDebit]["TellerID"].ToString();
                                    break;
                                }
                            }
                            DebitDGView.Rows[RowNumDebit].Cells["Comments"].Value       = aPurchaseVoucherTable.Rows[RowNumDebit]["Comments"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["CreditCardInfo"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["CreditCardInfo"].ToString();
                            for (int i = 0; i < aCurrencyTable.Rows.Count; i++)
                            {
                                if (int.Parse(aCurrencyTable.Rows[i]["ID"].ToString()) == int.Parse(aPurchaseVoucherTable.Rows[RowNumDebit]["CurrencyID"].ToString()))
                                {
                                    DebitDGView.Rows[RowNumDebit].Cells["Currency"].Value = aCurrencyTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNumDebit]["TellerID"].ToString();
                                    break;
                                }
                            }
                            for (int i = 0; i < aAccountsTable.Rows.Count; i++)
                            {
                                if (int.Parse(aAccountsTable.Rows[i]["ID"].ToString()) == int.Parse(aPurchaseVoucherTable.Rows[RowNumDebit]["AccountID"].ToString()))
                                {
                                    DebitDGView.Rows[RowNumDebit].Cells["Currency"].Value = aAccountsTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNumDebit]["TellerID"].ToString();
                                    break;
                                }
                            }
                            for (int i = 0; i < aUsersTable.Rows.Count; i++)
                            {
                                if (int.Parse(aUsersTable.Rows[i]["ID"].ToString()) == int.Parse(aPurchaseVoucherTable.Rows[RowNumDebit]["TellerID"].ToString()))
                                {
                                    DebitDGView.Rows[RowNumDebit].Cells["Teller"].Value = aUsersTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString();
                                    break;
                                }
                            }
                            DebitDGView.Rows[RowNumDebit].Cells["CheckNumber"].Value            = aPurchaseVoucherTable.Rows[RowNumDebit]["CheckNumber"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["IsCashCredit"].Value           = aPurchaseVoucherTable.Rows[RowNumDebit]["IsCashCredit"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["VendorAccountAmountOld"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["VendorAccountAmountOld"].ToString();
                            if (aPurchaseVoucherTable.Rows[RowNumDebit]["IsChecked"].ToString() == "0")
                            {
                                DebitDGView.Rows[RowNumDebit].Cells["IsChecked"].Value = "NO";//aBillTable.Rows[RowNumDebit]["IsChecked"].ToString();
                            }
                            else
                            {
                                DebitDGView.Rows[RowNumDebit].Cells["IsChecked"].Value = "YES";
                            }
                            DebitDGView.Rows[RowNumDebit].Cells["CheckedBy"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["CheckedBy"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["CheckDate"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["CheckDate"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["CheckTime"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["CheckTime"].ToString();
                            if (aPurchaseVoucherTable.Rows[RowNumDebit]["IsRevised"].ToString() == "0")
                            {
                                DebitDGView.Rows[RowNumDebit].Cells["IsRevised"].Value = "NO";//aBillTable.Rows[RowNumDebit]["IsChecked"].ToString();
                            }
                            else
                            {
                                DebitDGView.Rows[RowNumDebit].Cells["IsRevised"].Value = "YES";
                            }
                            DebitDGView.Rows[RowNumDebit].Cells["RevisedBy"].Value  = aPurchaseVoucherTable.Rows[RowNumDebit]["RevisedBy"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["ReviseDate"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["ReviseDate"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["ReviseTime"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["ReviseTime"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["ReviseLoss"].Value = aPurchaseVoucherTable.Rows[RowNumDebit]["ReviseLoss"].ToString();
                            DebitDGView.Rows[RowNumDebit].Cells["Fees"].Value       = aPurchaseVoucherTable.Rows[RowNumDebit]["Fees"].ToString();
                            RowNumDebit++;
                        }
                    }
                    PageOfTotalTxtBoxDebit.Text = "1/" + pagesnumberDebit.ToString();
                    currentpageDebit            = 1;
                }
            }

            //LISTING PAYMENTS
            //LISTING PAYMENTS CREDIT
            aVendorPaymentTable         = VendorsPaymentsMgmt.SelectAll(FilterTellerNameID, FilterDateFrom, FilterDateTo, FilterCheckedBills, FilterIsRevised, FilterUnCheckedBills, FilterUnRevisedBills, FilterVendorID);
            TotalITemsTxtBoxCredit.Text = aVendorPaymentTable.Rows.Count.ToString();

            TotalCreditTxtBox.Text = "0";
            if (aVendorPaymentTable.Rows.Count > 0)
            {
                double TotalCredit = 0;
                for (int i = 0; i < aVendorPaymentTable.Rows.Count; i++)
                {
                    TotalCredit += double.Parse(aVendorPaymentTable.Rows[i]["Amount"].ToString());
                }
                TotalCreditTxtBox.Text = TotalCredit.ToString();
                RowNumCredit           = 0;
                if (CreditDGView.Rows.Count < ItemsPerPageCredit)
                {
                    //TestingFor Paging
                    pagesnumberCredit = (int)aVendorPaymentTable.Rows.Count / ItemsPerPageCredit;
                    if ((double.Parse(aVendorPaymentTable.Rows.Count.ToString()) / ItemsPerPageCredit - int.Parse(aVendorPaymentTable.Rows.Count.ToString()) / ItemsPerPageCredit) > 0)
                    {
                        pagesnumberCredit++;
                    }
                    foreach (DataRow r in aVendorPaymentTable.Rows)
                    {
                        if (CreditDGView.Rows.Count < ItemsPerPageCredit)
                        {
                            CreditDGView.Rows.Add();
                            CreditDGView.Rows[RowNumCredit].Cells["PaymentNumber"].Value = aVendorPaymentTable.Rows[RowNumCredit]["PaymentNumber"].ToString();
                            for (int i = 0; i < aVendorTable.Rows.Count; i++)
                            {
                                if (int.Parse(aVendorTable.Rows[i]["ID"].ToString()) == int.Parse(aVendorPaymentTable.Rows[RowNumCredit]["VendorID"].ToString()))
                                {
                                    CreditDGView.Rows[RowNumCredit].Cells["VendorIDCredit"].Value = aVendorTable.Rows[i]["Name"].ToString();
                                    break;
                                }
                            }
                            CreditDGView.Rows[RowNumCredit].Cells["DateCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["Date"].ToString();
                            CreditDGView.Rows[RowNumCredit].Cells["TimeCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["Time"].ToString();
                            for (int i = 0; i < aUsersTable.Rows.Count; i++)
                            {
                                if (int.Parse(aUsersTable.Rows[i]["ID"].ToString()) == int.Parse(aVendorPaymentTable.Rows[RowNumCredit]["TellerID"].ToString()))
                                {
                                    CreditDGView.Rows[RowNumCredit].Cells["TellerCredit"].Value = aUsersTable.Rows[i]["UserName"].ToString();
                                    break;
                                }
                            }
                            CreditDGView.Rows[RowNumCredit].Cells["AmountCredit"].Value    = aVendorPaymentTable.Rows[RowNumCredit]["Amount"].ToString();
                            CreditDGView.Rows[RowNumCredit].Cells["OldAmountCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["OldVendorAccountAmount"].ToString();
                            CreditDGView.Rows[RowNumCredit].Cells["CommentsCredit"].Value  = aVendorPaymentTable.Rows[RowNumCredit]["Comments"].ToString();



                            if (aVendorPaymentTable.Rows[RowNumCredit]["IsChecked"].ToString() == "0")
                            {
                                CreditDGView.Rows[RowNumCredit].Cells["IsCheckedCredit"].Value = "NO";//aBillsDataTable.Rows[RowNum]["IsChecked"].ToString();
                            }
                            else
                            {
                                CreditDGView.Rows[RowNumCredit].Cells["IsCheckedCredit"].Value = "YES";
                            }

                            if (aVendorPaymentTable.Rows[RowNumCredit]["IsRevised"].ToString() == "0")
                            {
                                CreditDGView.Rows[RowNumCredit].Cells["IsRevisedCredit"].Value = "NO";//aBillsDataTable.Rows[RowNum]["IsRevised"].ToString();
                            }
                            else
                            {
                                CreditDGView.Rows[RowNumCredit].Cells["IsRevisedCredit"].Value = "YES";
                            }
                            CreditDGView.Rows[RowNumCredit].Cells["CheckDateCredit"].Value  = aVendorPaymentTable.Rows[RowNumCredit]["CheckDate"].ToString();
                            CreditDGView.Rows[RowNumCredit].Cells["CheckTimeCredit"].Value  = aVendorPaymentTable.Rows[RowNumCredit]["CheckTime"].ToString();
                            CreditDGView.Rows[RowNumCredit].Cells["CheckedByCredit"].Value  = aVendorPaymentTable.Rows[RowNumCredit]["CheckedBy"].ToString();
                            CreditDGView.Rows[RowNumCredit].Cells["ReviseDateCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["ReviseDate"].ToString();
                            CreditDGView.Rows[RowNumCredit].Cells["ReviseTimeCredit"].Value = aVendorPaymentTable.Rows[RowNumCredit]["ReviseTime"].ToString();
                            CreditDGView.Rows[RowNumCredit].Cells["RevisedByCredit"].Value  = aVendorPaymentTable.Rows[RowNumCredit]["RevisedBy"].ToString();
                            RowNumCredit++;
                        }
                        PageOfTotalTxtBoxCredit.Text = "1/" + pagesnumberCredit.ToString();
                        currentpageCredit            = 1;
                    }
                }
            }
        }
示例#3
0
        private void ListVouchersBtn_Click(object sender, EventArgs e)
        {
            try
            {
                int FilterVendorID = -1;
                if (ByVendorNameChkBox.Checked && VendorsComboBox.SelectedValue != null)
                {
                    FilterVendorID = int.Parse(VendorsComboBox.SelectedValue.ToString());//VendorsMgmt.SelectVendorIDByName(VendorNameTxtBox.Text);
                    // CustomerMgmt.SelectCustomerIDByPhone1(CustomerPhoneTxtBox.Text);
                    if (FilterVendorID == -1)
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + " " + MsgTxt.VendorTxt + " " + VendorsComboBox.Text + " " + MsgTxt.NotFoundTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                aVendorTable = VendorsMgmt.SelectAllVendors();
                if (aVendorTable == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListVouchersBtn_Click:DB-ERROR  aVendorTable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                aCurrencyTable = CurrencyMgmt.SelectAll();
                if (aCurrencyTable == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [aCurrencyTable:DB-ERROR  aCurrencyTable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                aUsersTable = UsersMgmt.SelectAllUsers();
                if (aUsersTable == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [aUsersTable:DB-ERROR  aUsersTable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                aAccountsTable = AccountsMgmt.SelectAll();
                if (aAccountsTable == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [aAccountsTable:DB-ERROR  aAccountsTable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                aPaymentMethodTable = PaymentMethodMgmt.SelectAll();
                if (aPaymentMethodTable == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [aPaymentMethodTable:DB-ERROR  aPaymentMethodTable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                //aVouchersTable = PurchaseVoucherGeneralMgmt.SelectAllVouchers();



                int FilterTellerID = 0;
                if (TellerNameChkBox.Checked && TellerNameComboBox.SelectedValue != null)
                {
                    FilterTellerID = int.Parse(TellerNameComboBox.SelectedValue.ToString());
                }

                string FilterDateFrom = "";
                string FilterDateTo   = "";
                if (DateCheckBox.Checked)
                {
                    FilterDateFrom = DateFrompicker.Value.ToShortDateString();
                    FilterDateTo   = DateToPicker.Value.ToShortDateString();
                }

                bool FilterChecked = CheckedChkBox.Checked;
                bool FilterRevised = IsRevisedChkBox.Checked;

                bool FilterUnChecked = UncheckedVouchersChkBox.Checked;
                bool FilterUnRevised = UnRevisedChkBox.Checked;

                aVouchersTable = PurchaseVoucherGeneralMgmt.SelectAllVouchers(FilterTellerID, FilterDateFrom, FilterDateTo, FilterChecked, FilterRevised, FilterUnChecked, FilterUnRevised, FilterVendorID, false);
                if (aVouchersTable == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [aVouchersTable:DB-ERROR  aVouchersTable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                TotalITemsTxtBox.Text = aVouchersTable.Rows.Count.ToString();
                ListVouchersDGView.Rows.Clear();
                if (aVouchersTable.Rows.Count > 0)
                {
                    RowNum = 0;
                    if (ListVouchersDGView.Rows.Count < ItemsPerPage)
                    {
                        //TestingFor Paging
                        pagesnumber = (int)aVouchersTable.Rows.Count / ItemsPerPage;
                        if ((double.Parse(aVouchersTable.Rows.Count.ToString()) / ItemsPerPage - int.Parse(aVouchersTable.Rows.Count.ToString()) / ItemsPerPage) > 0)
                        {
                            pagesnumber++;
                        }
                        foreach (DataRow r in aVouchersTable.Rows)
                        {
                            if (ListVouchersDGView.Rows.Count < ItemsPerPage)
                            {
                                ListVouchersDGView.Rows.Add();
                                ListVouchersDGView.Rows[RowNum].Cells["VoucherNumber"].Value = aVouchersTable.Rows[RowNum]["VoucherNumber"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["Date"].Value          = aVouchersTable.Rows[RowNum]["Date"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["Time"].Value          = aVouchersTable.Rows[RowNum]["Time"].ToString();
                                for (int i = 0; i < aVendorTable.Rows.Count; i++)
                                {
                                    if (int.Parse(aVendorTable.Rows[i]["ID"].ToString()) == int.Parse(aVouchersTable.Rows[RowNum]["VendorID"].ToString()))
                                    {
                                        ListVouchersDGView.Rows[RowNum].Cells["Vendor"].Value = aVendorTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString();
                                        break;
                                    }
                                }
                                ListVouchersDGView.Rows[RowNum].Cells["TotalFreeITemsQty"].Value  = aVouchersTable.Rows[RowNum]["TotalFreeITemsQty"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["TotalTax"].Value           = aVouchersTable.Rows[RowNum]["TotalTax"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["Subtotal"].Value           = aVouchersTable.Rows[RowNum]["Subtotal"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["DiscountPerc"].Value       = aVouchersTable.Rows[RowNum]["DiscountPerc"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["TotalItemsDiscount"].Value = aVouchersTable.Rows[RowNum]["TotalItemsDiscount"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["TotalDiscount"].Value      = aVouchersTable.Rows[RowNum]["TotalDiscount"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["TotalCost"].Value          = aVouchersTable.Rows[RowNum]["TotalCost"].ToString();
                                for (int i = 0; i < aPaymentMethodTable.Rows.Count; i++)
                                {
                                    if (int.Parse(aPaymentMethodTable.Rows[i]["ID"].ToString()) == int.Parse(aVouchersTable.Rows[RowNum]["PaymentMethodID"].ToString()))
                                    {
                                        ListVouchersDGView.Rows[RowNum].Cells["PaymentMethod"].Value = aPaymentMethodTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString();
                                        break;
                                    }
                                }
                                ListVouchersDGView.Rows[RowNum].Cells["Comments"].Value       = aVouchersTable.Rows[RowNum]["Comments"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["CreditCardInfo"].Value = aVouchersTable.Rows[RowNum]["CreditCardInfo"].ToString();
                                for (int i = 0; i < aCurrencyTable.Rows.Count; i++)
                                {
                                    if (int.Parse(aCurrencyTable.Rows[i]["ID"].ToString()) == int.Parse(aVouchersTable.Rows[RowNum]["CurrencyID"].ToString()))
                                    {
                                        ListVouchersDGView.Rows[RowNum].Cells["Currency"].Value = aCurrencyTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString();
                                        break;
                                    }
                                }
                                for (int i = 0; i < aAccountsTable.Rows.Count; i++)
                                {
                                    if (int.Parse(aAccountsTable.Rows[i]["ID"].ToString()) == int.Parse(aVouchersTable.Rows[RowNum]["AccountID"].ToString()))
                                    {
                                        ListVouchersDGView.Rows[RowNum].Cells["Currency"].Value = aAccountsTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString();
                                        break;
                                    }
                                }
                                for (int i = 0; i < aUsersTable.Rows.Count; i++)
                                {
                                    if (int.Parse(aUsersTable.Rows[i]["ID"].ToString()) == int.Parse(aVouchersTable.Rows[RowNum]["TellerID"].ToString()))
                                    {
                                        ListVouchersDGView.Rows[RowNum].Cells["Teller"].Value = aUsersTable.Rows[i]["Name"].ToString();//aBillTable.Rows[RowNum]["TellerID"].ToString();
                                        break;
                                    }
                                }
                                ListVouchersDGView.Rows[RowNum].Cells["CheckNumber"].Value            = aVouchersTable.Rows[RowNum]["CheckNumber"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["IsCashCredit"].Value           = aVouchersTable.Rows[RowNum]["IsCashCredit"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["VendorAccountAmountOld"].Value = aVouchersTable.Rows[RowNum]["VendorAccountAmountOld"].ToString();
                                if (aVouchersTable.Rows[RowNum]["IsChecked"].ToString() == "0")
                                {
                                    ListVouchersDGView.Rows[RowNum].Cells["IsChecked"].Value = "NO";//aBillTable.Rows[RowNum]["IsChecked"].ToString();
                                }
                                else
                                {
                                    ListVouchersDGView.Rows[RowNum].Cells["IsChecked"].Value = "YES";
                                }
                                ListVouchersDGView.Rows[RowNum].Cells["CheckedBy"].Value = aVouchersTable.Rows[RowNum]["CheckedBy"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["CheckDate"].Value = aVouchersTable.Rows[RowNum]["CheckDate"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["CheckTime"].Value = aVouchersTable.Rows[RowNum]["CheckTime"].ToString();
                                if (aVouchersTable.Rows[RowNum]["IsRevised"].ToString() == "0")
                                {
                                    ListVouchersDGView.Rows[RowNum].Cells["IsRevised"].Value = "NO";//aBillTable.Rows[RowNum]["IsChecked"].ToString();
                                }
                                else
                                {
                                    ListVouchersDGView.Rows[RowNum].Cells["IsRevised"].Value = "YES";
                                }
                                ListVouchersDGView.Rows[RowNum].Cells["RevisedBy"].Value  = aVouchersTable.Rows[RowNum]["RevisedBy"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["ReviseDate"].Value = aVouchersTable.Rows[RowNum]["ReviseDate"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["ReviseTime"].Value = aVouchersTable.Rows[RowNum]["ReviseTime"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["ReviseLoss"].Value = aVouchersTable.Rows[RowNum]["ReviseLoss"].ToString();
                                ListVouchersDGView.Rows[RowNum].Cells["Fees"].Value       = aVouchersTable.Rows[RowNum]["Fees"].ToString();
                                RowNum++;
                            }
                        }
                        PageOfTotalTxtBox.Text = "1/" + pagesnumber.ToString();
                        currentpage            = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListVouchersBtn_Click] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
示例#4
0
        public bool VendorsListReport(bool PrintToThermal, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool TableBorder = false, bool Preview = false, bool colored = false)
        {
            List <DataTable> aDTlist         = new List <DataTable>();
            DataTable        allVendorsTable = VendorsMgmt.SelectAllVendors();

            allVendorsTable.Columns.Remove("ID");
            if (TableBorder)
            {
                allVendorsTable.Columns[0].ColumnName = "[Border=true1]" + allVendorsTable.Columns[0].ColumnName;
            }

            //REMOVING EMPTY COLUMNS
            List <string> aColumnsToRemove = new List <string>();

            foreach (DataColumn aColumn in allVendorsTable.Columns)
            {
                bool ColumnEmpty = false;
                for (int i = 0; i < allVendorsTable.Rows.Count - 1; i++)
                {
                    if (allVendorsTable.Rows[i][aColumn].ToString().Trim() == "")
                    {
                        ColumnEmpty = true;
                    }
                    else
                    {
                        ColumnEmpty = false;
                        break;
                    }
                }
                if (ColumnEmpty)
                {
                    aColumnsToRemove.Add(aColumn.ColumnName);
                }
            }
            for (int i = 0; i < aColumnsToRemove.Count; i++)
            {
                allVendorsTable.Columns.Remove(aColumnsToRemove[i]);
            }
            //END REMOVING EMPTY COLUMNS

            aDTlist.Add(allVendorsTable);
            List <string> aHeaderList = ReportsHelper.ImportReportHeader(0, 1);
            List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 1);


            aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);
            aHeaderList.Add("<b><font size=4>" + "Vendors List Contact" + " </font>");
            aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);
            if (Preview)
            {
                PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", false, "", colored);
                return(true);
            }

            else if (ExportToPdf)
            {
                PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, true, ExportPath, false, "", colored);
                return(true);
            }
            else if (ExportToExcel)
            {
                PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", true, ExportPath, colored);
                return(true);
            }
            else if (PrintToThermal)
            {
                PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#5
0
        public bool VendorsBalanceListReport(bool PrintToThermal, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool TableBorder = false, bool Preview = false, bool colored = false)
        {
            List <DataTable> aDTlist = new List <DataTable>();

            DataTable aVendorsTable = VendorsMgmt.SelectAllVendors();

            aVendorsTable.Columns.Add("Balance");
            DataTable aVendorAccountTable = VendorsAccountsMgmt.SelectAll();

            if (aVendorsTable.Rows.Count > 0)
            {
                int RowNum = 0;
                foreach (DataRow r in aVendorsTable.Rows)
                {
                    if (aVendorAccountTable != null)
                    {
                        for (int i = 0; i < aVendorAccountTable.Rows.Count; i++)
                        {
                            if (int.Parse(aVendorsTable.Rows[RowNum]["ID"].ToString()) == int.Parse(aVendorAccountTable.Rows[i]["VendorID"].ToString()))
                            {
                                aVendorsTable.Rows[RowNum]["Balance"] = aVendorAccountTable.Rows[i]["Amount"].ToString();
                            }
                        }
                    }
                    RowNum++;
                }
                aVendorsTable.Columns.Remove("ID");
                if (TableBorder)
                {
                    aVendorsTable.Columns[0].ColumnName = "[Border=true1]" + aVendorsTable.Columns[0].ColumnName;
                }

                //REMOVING EMPTY COLUMNS
                List <string> aColumnsToRemove = new List <string>();
                foreach (DataColumn aColumn in aVendorsTable.Columns)
                {
                    bool ColumnEmpty = false;
                    for (int i = 0; i < aVendorsTable.Rows.Count - 1; i++)
                    {
                        if (aVendorsTable.Rows[i][aColumn].ToString().Trim() == "")
                        {
                            ColumnEmpty = true;
                        }
                        else
                        {
                            ColumnEmpty = false;
                            break;
                        }
                    }
                    if (ColumnEmpty)
                    {
                        aColumnsToRemove.Add(aColumn.ColumnName);
                    }
                }
                for (int i = 0; i < aColumnsToRemove.Count; i++)
                {
                    aVendorsTable.Columns.Remove(aColumnsToRemove[i]);
                }
                //END REMOVING EMPTY COLUMNS


                aDTlist.Add(aVendorsTable);

                List <string> aHeaderList = ReportsHelper.ImportReportHeader(0, 1);
                List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 1);
                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);
                aHeaderList.Add("<b><font size=4>" + "Vendors Balances List" + " </font>");
                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);

                if (Preview)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", false, "", colored);
                    return(true);
                }

                else if (ExportToPdf)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, true, ExportPath, false, "", colored);
                    return(true);
                }
                else if (ExportToExcel)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", true, ExportPath, colored);
                    return(true);
                }
                else if (PrintToThermal)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false); //there is no items in the customer table
            }
        }
示例#6
0
        private void Add1000PurchaseVoucherBtn_Click(object sender, EventArgs e)
        {
            Random randAmount = new Random();
            int    cnt        = 1;
            var    Vendors    = VendorsMgmt.SelectAllVendors();
            int    userId     = int.Parse(UsersMgmt.SelectAllUsers().Rows[0]["ID"].ToString());

            while (cnt++ < NumberOfPurchases)
            {
                try
                {
                    PurchaseVoucherGeneral aPurchaseGeneral = new PurchaseVoucherGeneral();
                    aPurchaseGeneral.AccountID              = 1;
                    aPurchaseGeneral.Comments               = "";
                    aPurchaseGeneral.CurrencyID             = 1;
                    aPurchaseGeneral.Date                   = DateTime.Now.Subtract(TimeSpan.FromDays(randAmount.Next(1, 2000))).ToShortDateString();
                    aPurchaseGeneral.DiscountPerc           = 0;
                    aPurchaseGeneral.Fees                   = 10;
                    aPurchaseGeneral.IsCashCredit           = 0;
                    aPurchaseGeneral.IsChecked              = 0;
                    aPurchaseGeneral.IsRevised              = 0;
                    aPurchaseGeneral.PaymentMethodID        = 1;
                    aPurchaseGeneral.Subtotal               = 100;
                    aPurchaseGeneral.TellerID               = userId;
                    aPurchaseGeneral.Time                   = DateTime.Now.ToShortTimeString();
                    aPurchaseGeneral.TotalCost              = 90;
                    aPurchaseGeneral.TotalDiscount          = 0;
                    aPurchaseGeneral.TotalFreeItemsQty      = 0;
                    aPurchaseGeneral.TotalItemsDiscount     = 0;
                    aPurchaseGeneral.TotalTax               = 10;
                    aPurchaseGeneral.VendorAccountAmountOld = 0;
                    aPurchaseGeneral.VendorID               =
                        int.Parse(Vendors.Rows[(int)NumberOfPurchases % Vendors.Rows.Count]["ID"].ToString());
                    aPurchaseGeneral.VoucherNumber  = PurchaseVoucherGeneralMgmt.NextVoucherNumber();
                    aPurchaseGeneral.CreditCardInfo = "";


                    int NumofDetailed = randAmount.Next(1, 20);
                    if (PurchaseVoucherGeneralMgmt.AddVoucher(aPurchaseGeneral))
                    {
                        while (NumofDetailed > 0)
                        {
                            PurchaseVoucherDetailed aPurchaseDetailed = new PurchaseVoucherDetailed();
                            string    aBarcode = "Test Item " + randAmount.Next(1, (int)NumberOfItems).ToString();
                            DataTable aItemRow = ItemsMgmt.SelectItemByBarCode(aBarcode);
                            if (aItemRow.Rows.Count != 0)
                            {
                                aPurchaseDetailed.Purchase_Voucher_Detailed_ItemID =
                                    int.Parse(aItemRow.Rows[0]["ID"].ToString());
                                aPurchaseDetailed.Purchase_Voucher_Detailed_VoucherNumber =
                                    aPurchaseGeneral.VoucherNumber;
                                aPurchaseDetailed.Purchase_Voucher_Detailed_IsRevised = 0;
                                aPurchaseDetailed.Purchase_Voucher_Detailed_ItemCost  =
                                    double.Parse(aItemRow.Rows[0]["AvgUnitCost"].ToString());
                                aPurchaseDetailed.Purchase_Voucher_Detailed_OldAvaQty =
                                    double.Parse(aItemRow.Rows[0]["Qty"].ToString());
                                aPurchaseDetailed.Purchase_Voucher_Detailed_Qty      = NumofDetailed;
                                aPurchaseDetailed.Purchase_Voucher_Detailed_Discount = 0;
                                // = double.Parse(aItemRow.Rows[0]["SellPrice"].ToString());
                                aPurchaseDetailed.Purchase_Voucher_Detailed_FreeItemsQty = 0;
                                // aBillDetailed.Bill_Detailed_TotalPerUnit = aBillDetailed.Bill_Detailed_Qty * aBillDetailed.Bill_Detailed_SellPrice;
                                PurchaseVoucherDetailedMgmt.AddItem(aPurchaseDetailed);
                            }
                            NumofDetailed--;
                        }
                    }
                    if (cnt % 100 == 0)
                    {
                        label1.Text = $"Adding Purchase Order {cnt}/{NumberOfPurchases} ... ({(cnt / NumberOfPurchases) * 100 })%";
                        Application.DoEvents();
                    }
                }
                catch (Exception ex) { MessageBox.Show($"Error in {cnt} \n {ex}"); }
            }
        }
示例#7
0
        private void ListItemsBtn_Click(object sender, EventArgs e)
        {
            try
            {
                ListItemsDgView.Rows.Clear();
                if (RndrPointChkBox.Checked)
                {
                    ItemsDatatable = ItemsMgmt.RenderPoint();
                }
                else
                {
                    ItemsDatatable = ItemsMgmt.SelectAllItems();
                }

                if (ItemsDatatable == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListItemsBtn_Click:DB-ERROR  ItemsDatatable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }


                TotalITemsTxtBox.Text = ItemsDatatable.Rows.Count.ToString();

                TaxLevelDataTable     = ItemTaxLevelMgmt.SelectAll();
                ItemCategoryDataTable = ItemCategoryMgmt.SelectAll();
                VendorsDataTable      = VendorsMgmt.SelectAllVendors();
                ItemsTypeDataTalbe    = ItemTypeMgmt.SelectAll();
                if (TaxLevelDataTable == null || ItemCategoryDataTable == null || VendorsDataTable == null || ItemsTypeDataTalbe == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListItemsBtn_Click:DB-ERROR  TaxLevelDataTable=null ||ItemCategoryDataTable=null || VendorsDataTable==null ||  ItemsTypeDataTalbe==null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                taxlevelrowsnumber     = TaxLevelDataTable.Rows.Count;
                itemcategoryrowsnumber = ItemCategoryDataTable.Rows.Count;
                vendorrowsnumber       = VendorsDataTable.Rows.Count;
                typerowsnumber         = ItemsTypeDataTalbe.Rows.Count;

                if (ItemsDatatable.Rows.Count > 0)
                {
                    //TestingFor Paging
                    pagesnumber = (int)ItemsDatatable.Rows.Count / ItemsPerPage;
                    if ((double.Parse(ItemsDatatable.Rows.Count.ToString()) / ItemsPerPage - int.Parse(ItemsDatatable.Rows.Count.ToString()) / ItemsPerPage) > 0)
                    {
                        pagesnumber++;
                    }

                    RowNum = 0;
                    ListItemsDgView.Rows.Clear();
                    foreach (DataRow r in ItemsDatatable.Rows)
                    {
                        if (ListItemsDgView.Rows.Count < ItemsPerPage)
                        {
                            ListItemsDgView.Rows.Add();
                            // TRIAL 2 CODE
                            ListItemsDgView.Rows[RowNum].Cells["Barcode"].Value = ItemsDatatable.Rows[RowNum]["Barcode"].ToString();
                            for (int i = 0; i < typerowsnumber; i++)
                            {
                                if (int.Parse(ItemsTypeDataTalbe.Rows[i]["ID"].ToString()) == int.Parse(ItemsDatatable.Rows[RowNum]["Type"].ToString()))
                                {
                                    ListItemsDgView.Rows[RowNum].Cells["Type"].Value = ItemsTypeDataTalbe.Rows[i]["Name"].ToString();
                                    break;
                                }
                            }
                            for (int i = 0; i < itemcategoryrowsnumber; i++)
                            {
                                if (int.Parse(ItemCategoryDataTable.Rows[i]["ID"].ToString()) == int.Parse(ItemsDatatable.Rows[RowNum]["Category"].ToString()))
                                {
                                    ListItemsDgView.Rows[RowNum].Cells["Category"].Value = ItemCategoryDataTable.Rows[i]["Name"].ToString();
                                    break;
                                }
                            }
                            for (int i = 0; i < taxlevelrowsnumber; i++)
                            {
                                if (int.Parse(TaxLevelDataTable.Rows[i]["ID"].ToString()) == int.Parse(ItemsDatatable.Rows[RowNum]["TaxLevel"].ToString()))
                                {
                                    ListItemsDgView.Rows[RowNum].Cells["TaxLevel"].Value = TaxLevelDataTable.Rows[i]["Percentage"].ToString();
                                    break;
                                }
                            }
                            for (int i = 0; i < vendorrowsnumber; i++)
                            {
                                if (int.Parse(VendorsDataTable.Rows[i]["ID"].ToString()) == int.Parse(ItemsDatatable.Rows[RowNum]["Vendor"].ToString()))
                                {
                                    ListItemsDgView.Rows[RowNum].Cells["Vendor"].Value = VendorsDataTable.Rows[i]["Name"].ToString();
                                    break;
                                }
                            }
                            ListItemsDgView.Rows[RowNum].Cells["Description"].Value = ItemsDatatable.Rows[RowNum]["Description"].ToString();
                            ListItemsDgView.Rows[RowNum].Cells["Qty"].Value         = ItemsDatatable.Rows[RowNum]["Qty"].ToString();
                            ListItemsDgView.Rows[RowNum].Cells["AvgUnitCost"].Value = Math.Round(double.Parse(ItemsDatatable.Rows[RowNum]["AvgUnitCost"].ToString()), 3);
                            ListItemsDgView.Rows[RowNum].Cells["SellPrice"].Value   = ItemsDatatable.Rows[RowNum]["SellPrice"].ToString();
                            ListItemsDgView.Rows[RowNum].Cells["RenderPoint"].Value = ItemsDatatable.Rows[RowNum]["RenderPoint"].ToString();
                            ListItemsDgView.Rows[RowNum].Cells["Margincol"].Value   = (Convert.ToDouble(ListItemsDgView.Rows[RowNum].Cells["SellPrice"].Value) - Convert.ToDouble(ListItemsDgView.Rows[RowNum].Cells["AvgUnitCost"].Value)) / Convert.ToDouble(ListItemsDgView.Rows[RowNum].Cells["AvgUnitCost"].Value) * 100;
                            ListItemsDgView.Rows[RowNum].Cells["DateAdded"].Value   = ItemsDatatable.Rows[RowNum]["EntryDate"].ToString();
                            RowNum++;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListCustomersBtn_Click] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }

            /* TimeSpan ts = DateTime.Now.Subtract(StartTime);
             * string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
             *       ts.Hours, ts.Minutes, ts.Seconds,
             *       ts.Milliseconds / 10);*/
            PageOfTotalTxtBox.Text = "1/" + pagesnumber.ToString();
            currentpage            = 1;
            // Console.WriteLine(elapsedTime, "RunTime");

            // MessageBox.Show("Elasped Time in Seconds for [[1,300]] items [TRIAL 2 new code] is =" + elapsedTime);
        }
示例#8
0
        private void ListVendorsBtn_Click(object sender, EventArgs e)
        {
            try
            {
                aVendorTable = VendorsMgmt.SelectAllVendors();
                if (aVendorTable == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListVendorsBtn_Click:DB-ERROR  aVendorTable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                aVendorAccountTable = VendorsAccountsMgmt.SelectAll();
                if (aVendorAccountTable == null && aVendorTable.Rows.Count != 0)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListVendorsBtn_Click:DB-ERROR  aVendorAccountTable=null] \n  \n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                TotalITemsTxtBox.Text = aVendorTable.Rows.Count.ToString();
                if (aVendorTable.Rows.Count > 0)
                {
                    pagesnumber = (int)aVendorTable.Rows.Count / ItemsPerPage;
                    if ((double.Parse(aVendorTable.Rows.Count.ToString()) / ItemsPerPage - int.Parse(aVendorTable.Rows.Count.ToString()) / ItemsPerPage) > 0)
                    {
                        pagesnumber++;
                    }

                    RowNum = 0;
                    ListVendorsDGView.Rows.Clear();

                    foreach (DataRow r in aVendorTable.Rows)
                    {
                        if (ListVendorsDGView.Rows.Count < ItemsPerPage)
                        {
                            ListVendorsDGView.Rows.Add();
                            ListVendorsDGView.Rows[RowNum].Cells["Namecol"].Value     = aVendorTable.Rows[RowNum]["Name"].ToString();
                            ListVendorsDGView.Rows[RowNum].Cells["Locationcol"].Value = aVendorTable.Rows[RowNum]["Location"].ToString();
                            ListVendorsDGView.Rows[RowNum].Cells["Phone1"].Value      = aVendorTable.Rows[RowNum]["Phone1"].ToString();
                            ListVendorsDGView.Rows[RowNum].Cells["Phone2"].Value      = aVendorTable.Rows[RowNum]["Phone2"].ToString();
                            ListVendorsDGView.Rows[RowNum].Cells["Email"].Value       = aVendorTable.Rows[RowNum]["Email"].ToString();
                            ListVendorsDGView.Rows[RowNum].Cells["Company"].Value     = aVendorTable.Rows[RowNum]["Company"].ToString();
                            ListVendorsDGView.Rows[RowNum].Cells["StartDate"].Value   = Convert.ToDateTime(aVendorTable.Rows[RowNum]["StartDate"].ToString()).ToShortDateString();
                            if (aVendorTable != null)
                            {
                                for (int i = 0; i < aVendorAccountTable.Rows.Count; i++)
                                {
                                    if (int.Parse(aVendorTable.Rows[RowNum]["ID"].ToString()) == int.Parse(aVendorAccountTable.Rows[i]["VendorID"].ToString()))
                                    {
                                        ListVendorsDGView.Rows[RowNum].Cells["AccountAmount"].Value = aVendorAccountTable.Rows[i]["Amount"].ToString();
                                    }
                                }
                            }
                            RowNum++;
                        }
                    }
                    PageOfTotalTxtBox.Text = "1/" + pagesnumber.ToString();
                    currentpage            = 1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListVendorsBtn_Click] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
示例#9
0
        public bool PrintItemsList(bool RenderPoint, bool PrintToThermal, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool TableBorder = false, bool Preview = false, bool colored = false)
        {
            try
            {
                List <DataTable> aDTlist        = new List <DataTable>();
                DataTable        ItemsDatatable = null;

                if (RenderPoint)
                {
                    ItemsDatatable = ItemsMgmt.RenderPoint();
                }
                else
                {
                    ItemsDatatable = ItemsMgmt.SelectAllItems();
                }
                if (ItemsDatatable == null)
                {
                    return(false);
                }
                else
                {
                    if (ItemsDatatable.Rows.Count == 0)
                    {
                        return(false);
                    }
                }

                DataTable ItemCategoryDataTable  = ItemCategoryMgmt.SelectAll();
                DataTable VendorsDataTable       = VendorsMgmt.SelectAllVendors();
                DataTable ItemsTypeDataTalbe     = ItemTypeMgmt.SelectAll();
                int       itemcategoryrowsnumber = ItemCategoryDataTable.Rows.Count;
                int       vendorrowsnumber       = VendorsDataTable.Rows.Count;
                int       typerowsnumber         = ItemsTypeDataTalbe.Rows.Count;

                DataTable ToPrintTable = new DataTable();
                ToPrintTable.Columns.Add("Barcode");
                ToPrintTable.Columns.Add("Description");
                ToPrintTable.Columns.Add("Ava.Qty");
                ToPrintTable.Columns.Add("Avg Cost");
                ToPrintTable.Columns.Add("Type");
                ToPrintTable.Columns.Add("Category");
                ToPrintTable.Columns.Add("Pref.Vendor");
                if (RenderPoint)
                {
                    ToPrintTable.Columns.Add("Phone");
                }

                foreach (DataRow r in ItemsDatatable.Rows)
                {
                    DataRow aRow = ToPrintTable.Rows.Add();
                    aRow["Barcode"]     = r["Barcode"];
                    aRow["Description"] = r["Description"];
                    aRow["Ava.Qty"]     = Math.Round(double.Parse(r["Qty"].ToString()), 3);
                    aRow["Avg Cost"]    = Math.Round(double.Parse(r["AvgUnitCost"].ToString()), 3);
                    for (int i = 0; i < typerowsnumber; i++)
                    {
                        if (int.Parse(ItemsTypeDataTalbe.Rows[i]["ID"].ToString()) == int.Parse(r["Type"].ToString()))
                        {
                            aRow["Type"] = ItemsTypeDataTalbe.Rows[i]["Name"].ToString();
                            break;
                        }
                    }
                    for (int i = 0; i < itemcategoryrowsnumber; i++)
                    {
                        if (int.Parse(ItemCategoryDataTable.Rows[i]["ID"].ToString()) == int.Parse(r["Category"].ToString()))
                        {
                            aRow["Category"] = ItemCategoryDataTable.Rows[i]["Name"].ToString();
                            break;
                        }
                    }

                    for (int i = 0; i < vendorrowsnumber; i++)
                    {
                        if (int.Parse(VendorsDataTable.Rows[i]["ID"].ToString()) == int.Parse(r["Vendor"].ToString()))
                        {
                            aRow["Pref.Vendor"] = VendorsDataTable.Rows[i]["Name"].ToString();
                            if (RenderPoint)
                            {
                                aRow["Phone"] = VendorsDataTable.Rows[i]["Phone1"].ToString();
                            }
                            break;
                        }
                    }
                }

                if (TableBorder)
                {
                    ToPrintTable.Columns[0].ColumnName = "[Border=true1]" + ToPrintTable.Columns[0].ColumnName;
                }
                if (RenderPoint)
                {
                    ToPrintTable.Columns.Remove("Category");
                }
                ToPrintTable.Columns["Description"].ColumnName = ("<th width=30%> Description");
                ToPrintTable.Columns.Remove("Type");
                aDTlist.Add(ToPrintTable);
                List <string> aHeaderList = ReportsHelper.ImportReportHeader(0, 1);
                List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 1);

                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);
                if (RenderPoint)
                {
                    aHeaderList.Add("<b><font size=4>" + Text.ReportsNames.RenPointListRepNm + " </font>");
                }
                else
                {
                    aHeaderList.Add("<b><font size=4>" + Text.ReportsNames.ItemsListRepNm + " </font>");
                }

                aHeaderList.Add("<b><font size=2>" + Text.ReportsText.DateRepTxt + ": " + DateTime.Now.ToShortDateString() + " </font>");
                aHeaderList.Add("<td>" + SharedVariables.Line_Solid_10px_Black);
                if (Preview)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", false, "", colored);
                    return(true);
                }

                else if (ExportToPdf)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, true, ExportPath, false, "", colored);
                    return(true);
                }
                else if (ExportToExcel)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", true, ExportPath, colored);
                    return(true);
                }
                else if (PrintToThermal)
                {
                    PrintingManager.Instance.PrintTables(aDTlist, aHeaderList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true, false, "", false, "", colored);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }