コード例 #1
0
ファイル: EditVoucher.cs プロジェクト: SariSultan/RMS
        private bool print_receipt()
        {
            try
            {
                List <DataTable> aDataTableList = new List <DataTable>();
                DataTable        aDataTable1    = new DataTable();
                aDataTable1.Columns.Add("[border=true1]<th width=45%>" + ReceiptText.RctTxtItemName);
                aDataTable1.Columns.Add(ReceiptText.RctTxtUnitPrice);
                aDataTable1.Columns.Add(ReceiptText.RctTxtQty);
                aDataTable1.Columns.Add(ReceiptText.RctTxtTotal);
                aDataTable1.Columns.Add(ReceiptText.RctTxtDiscount + " %");

                bool NoDiscount = true;
                foreach (DataGridViewRow aRow in TeldgView.Rows)
                {
                    aDataTable1.Rows.Add();
                    aDataTable1.Rows[aRow.Index][0] = aRow.Cells["Description"].Value.ToString();
                    aDataTable1.Rows[aRow.Index][1] = aRow.Cells["PricePerUnit"].Value.ToString();
                    aDataTable1.Rows[aRow.Index][2] = aRow.Cells["Qty"].Value.ToString();
                    aDataTable1.Rows[aRow.Index][3] = aRow.Cells["PriceTotal"].Value.ToString();

                    aDataTable1.Rows[aRow.Index][4] = aRow.Cells["DiscountPerc"].Value.ToString();
                    if (double.Parse(aRow.Cells["DiscountPerc"].Value.ToString()) > 0)
                    {
                        NoDiscount = false;
                    }
                }

                if (NoDiscount)
                {
                    aDataTable1.Columns.Remove(aDataTable1.Columns[4]);
                }
                int       RowCnt      = 0;
                DataTable aDataTable3 = new DataTable();
                aDataTable3.Columns.Add("[border=true1]<th>" + ReceiptText.RctTxtSubTotal);
                aDataTable3.Columns.Add(SubtotalTxtBox.Text + "JOD");
                RowCnt = 0;

                aDataTable3.Rows.Add();
                aDataTable3.Rows[RowCnt][0]   = ReceiptText.RctTxtTax;
                aDataTable3.Rows[RowCnt++][1] = TotalTaxTxtBox.Text + "<b> JOD";

                if (double.Parse(DiscountTxtBox.Text) != 0)
                {
                    aDataTable3.Rows.Add();
                    aDataTable3.Rows[RowCnt][0]   = ReceiptText.RctTxtVoucherDiscount;
                    aDataTable3.Rows[RowCnt++][1] = "@" + DiscountPercTxtBox.Text + "% =" + DiscountTxtBox.Text + "<b> JOD";
                }
                if (double.Parse(ItemsDiscountTxtBox.Text) != 0)
                {
                    aDataTable3.Rows.Add();
                    aDataTable3.Rows[RowCnt][0]   = ReceiptText.RctTxtItemsDiscount;
                    aDataTable3.Rows[RowCnt++][1] = ItemsDiscountTxtBox.Text + "<b> JOD";
                }
                if (double.Parse(TotalDiscountTxtBox.Text) != 0)
                {
                    aDataTable3.Rows.Add();
                    aDataTable3.Rows[RowCnt][0]   = ReceiptText.RctTxtTotalDiscount;
                    aDataTable3.Rows[RowCnt++][1] = TotalDiscountTxtBox.Text + "<b> JOD";
                }
                if (double.Parse(FeesTxtBox.Text) != 0)
                {
                    aDataTable3.Rows.Add();
                    aDataTable3.Rows[RowCnt][0]   = ReceiptText.RctTxtFees;
                    aDataTable3.Rows[RowCnt++][1] = FeesTxtBox.Text + "<b> JOD";
                }


                aDataTable3.Rows.Add();
                aDataTable3.Rows[RowCnt][0]   = "<td style=\"background-color:#000;color:#fff;border-right-color:#fff;\"><b><font size=4>" + ReceiptText.RctTxtToPayAmount + "</font>";
                aDataTable3.Rows[RowCnt++][1] = "<td style=\"background-color:#000;color:#fff;border-left-color:#fff\"><b><font size=5>" + TotalTxtBox.Text + " JOD </font>";

                aDataTable3.Rows.Add();
                aDataTable3.Rows[RowCnt][0]   = ReceiptText.RctTxtPayMethod;
                aDataTable3.Rows[RowCnt++][1] = PaymentMethodCheckBox.Text;
                if (PaymentMethodCheckBox.Text.ToUpper() == "CASH")
                {
                    if (CashMethodComboBox.Text == "Cash")
                    {
                        aDataTable3.Rows.Add();
                        aDataTable3.Rows[RowCnt][0]   = ReceiptText.RctTxtCashIn;
                        aDataTable3.Rows[RowCnt++][1] = CashInTxtBox.Text + "<b> " + " JOD";
                        double tempamt = 0;
                        if (double.TryParse(ExchangeTxtBox.Text, out tempamt))
                        {
                            if (tempamt != 0)
                            {
                                aDataTable3.Rows.Add();
                                aDataTable3.Rows[RowCnt][0]   = ReceiptText.RctTxtExchange;
                                aDataTable3.Rows[RowCnt++][1] = ExchangeTxtBox.Text + "<b> JOD";
                            }
                        }
                    }
                    else if (CashMethodComboBox.Text == "Invoice")
                    {
                        aDataTable3.Rows.Add();
                        aDataTable3.Rows[RowCnt][0] = ReceiptText.RctTxtPayable;
                        double VendorAccountAmountParserChk = 0;
                        if (double.TryParse(VendorAccountAmountTxtBox.Text, out VendorAccountAmountParserChk))
                        {
                            aDataTable3.Rows[RowCnt++][1] = ReceiptText.RctTxtOldBalance + " = " + VendorAccountAmountParserChk + "&nbsp;&nbsp;" + SharedVariables.Line_Solid_10px_Black +
                                                            ReceiptText.RctTxtNewBalance + " = " + Math.Round((VendorAccountAmountParserChk + double.Parse(TotalTxtBox.Text)), 3);
                        }
                    }
                }

                aDataTableList.Add(aDataTable1);
                // aDataTableList.Add(aDataTable2);
                aDataTableList.Add(aDataTable3);

                List <string> aStringList = ReportsHelper.ImportReportHeader(0, 0);
                List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 0);

                aStringList.Add(SharedVariables.Line_Solid_10px_Black);
                aStringList.Add(ReceiptName.RctNmsPurchase);


                aStringList.Add("*** " + ReceiptText.RctTxtDuplicate + " ***");
                if (aPurchaseDataRow["IsRevised"].ToString() == "1")
                {
                    aStringList.Add("*** " + ReceiptText.RctTxtReversed + " ***");
                    aStringList.Add("<h2> " + ReceiptText.RctTxtReversedBy + ":&nbsp;&nbsp;" + RevisedBylbl.Text + "</h2>");
                    aStringList.Add("<h2> " + ReceiptText.RctTxtReversedOn + ":&nbsp;&nbsp;" + ReviseDatelbl.Text + "</h2>");
                }

                aStringList.Add("<h2>" + ReceiptText.RctTxtOrgDate + "/" + ReceiptText.RctTxtOrgTime + " " + DateLbl.Text + "&nbsp;&nbsp;" + TimeLbl.Text + "</h2>");
                aStringList.Add("<h2> " + ReceiptText.RctTxtOrgTeller + ":&nbsp;&nbsp;" + TellerLbl.Text + "</h2>");
                aStringList.Add("<h2>" + ReceiptText.RctTxtReprintedOn + " " + DateTime.Now.ToShortDateString() + "&nbsp;&nbsp;" + DateTime.Now.ToShortTimeString() + "</h2>");
                aStringList.Add("<h2> " + ReceiptText.RctTxtReprintedBy + ":&nbsp;&nbsp;" + SharedFunctions.ReturnLoggedUserName() + "</h2>");

                aStringList.Add("<h2> " + ReceiptText.RctTxtVendor + ":&nbsp;&nbsp;" + VendorsComboBox.Text + "</h2>");


                aStringList.Add(ReceiptText.RctTxtPurchaseNumber + ":&nbsp; " + PurchaseVoucherNumTxtBox.Text);
                aStringList.Add(SharedVariables.Line_Solid_10px_Black);

                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n Exception: IN[Edit PurchaseVoucher:Print Receipt [EXCEPTION IS]] \n" + ex.Message, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
コード例 #2
0
        private bool print_receipt()
        {
            try
            {
                List <DataTable> aDataTableList = new List <DataTable>();
                DataTable        aDataTable1    = new DataTable();
                aDataTable1.Columns.Add("[border=true1]<th width=45%>" + ReceiptText.RctTxtItemName);
                aDataTable1.Columns.Add(ReceiptText.RctTxtUnitCost);
                aDataTable1.Columns.Add(ReceiptText.RctTxtQty);
                aDataTable1.Columns.Add(ReceiptText.RctTxtTotal);

                foreach (DataGridViewRow aRow in TeldgView.Rows)
                {
                    aDataTable1.Rows.Add();
                    aDataTable1.Rows[aRow.Index][0] = aRow.Cells["Description"].Value.ToString();
                    aDataTable1.Rows[aRow.Index][1] = aRow.Cells["PricePerUnit"].Value.ToString();
                    aDataTable1.Rows[aRow.Index][2] = aRow.Cells["Qty"].Value.ToString();
                    aDataTable1.Rows[aRow.Index][3] = aRow.Cells["PriceTotal"].Value.ToString();
                }
                int       RowCnt      = 0;
                DataTable aDataTable3 = new DataTable();
                aDataTable3.Columns.Add("[border=true1]<th>" + ReceiptText.RctTxtTax);
                aDataTable3.Columns.Add(TaxTxtBox.Text + "JOD");
                RowCnt = 0;


                aDataTable3.Rows.Add();
                aDataTable3.Rows[RowCnt][0]   = "<td style=\"background-color:#000;color:#fff;border-right-color:#fff;\"><b><font size=4>" + ReceiptText.RctTxtTotal + "</font>";
                aDataTable3.Rows[RowCnt++][1] = "<td style=\"background-color:#000;color:#fff;border-left-color:#fff\"><b><font size=5>" + TotalTxtBox.Text + " JOD </font>";

                aDataTable3.Rows.Add();
                aDataTable3.Rows[RowCnt][0]   = ReceiptText.RctTxtDisposalReason;
                aDataTable3.Rows[RowCnt++][1] = DisposalReasonComboBox.Text;

                aDataTableList.Add(aDataTable1);
                // aDataTableList.Add(aDataTable2);
                aDataTableList.Add(aDataTable3);

                List <string> aStringList = ReportsHelper.ImportReportHeader(0, 0);
                List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 0);

                aStringList.Add(SharedVariables.Line_Solid_10px_Black);
                aStringList.Add(ReceiptName.RctNmsDisposeitems);
                aStringList.Add("<h2>" + ReceiptText.RctTxtDate + "/" + ReceiptText.RctTxtTime + " " + DateTime.Now.ToShortDateString() + "&nbsp;&nbsp;" + DateTime.Now.ToShortTimeString() + "</h2>");
                aStringList.Add("<h2> " + ReceiptText.RctTxtTeller + ":&nbsp;&nbsp;" + SharedFunctions.ReturnLoggedUserName() + "</h2>");

                aStringList.Add(ReceiptText.RctTxtDisposeInvNumber + ":&nbsp; " + InvoiceNumTxtBox.Text);
                aStringList.Add(SharedVariables.Line_Solid_10px_Black);
                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, !PrintingThermalA4ChkBox.Checked, !PrintingThermalA4ChkBox.Checked, PrintingThermalA4ChkBox.Checked, ReportsHelper.TempOutputPath + ".pdf", false, "", false, PrintingThermalA4ChkBox.Checked);
                if (PrintingThermalA4ChkBox.Checked)
                {
                    Process.Start(ReportsHelper.TempPDFOutputPath);
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n Exception: IN[DisposeItems:Print Receipt [EXCEPTION IS]] \n" + ex.Message, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
コード例 #3
0
        private void ReviseBillBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (aBillGeneralRow["IsRevised"].ToString() == "0")
                {
                    if (CashMethodComboBox.SelectedIndex == 1)//iscredit
                    {
                        int     CustomerID       = CustomerMgmt.SelectCustomerIDByPhone1(PhoneTxtBox.Text);
                        DataRow aCustomerAccount = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID);
                        double  OldAmount        = double.Parse(aCustomerAccount["Amount"].ToString());
                        double  NewAmount        = OldAmount - double.Parse(TotalTxtBox.Text);
                        int     AccountID        = int.Parse(aCustomerAccount["ID"].ToString());
                        CustomersAccountsMgmt.UpdateAccountAmountByAccountID(AccountID, NewAmount);
                    }
                    else
                    {//int.Parse(AccountComboBox.SelectedValue.ToString());
                        int     AccountID   = int.Parse(aBillGeneralRow["AccountID"].ToString());
                        DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(AccountID);
                        double  OldAmount   = double.Parse(aAccountRow["Amount"].ToString());
                        double  NewAmount   = OldAmount - double.Parse(TotalTxtBox.Text);;
                        AccountsMgmt.UpdateAccountAmountByAccountID(AccountID, NewAmount);
                    }
                    //Mark the check (if any) as revised
                    DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(aBillGeneralRow["PaymentMethodID"].ToString()));
                    if (aMethodRow["IsCheck"].ToString() == "1")
                    {
                        ChecksMgmt.MakeCheckRevised(int.Parse(aBillGeneralRow["CheckNumber"].ToString()), DateTime.Now.ToShortDateString());
                    }
                    //Now Update AvgUnitCost
                    double CostLoss = 0;
                    foreach (DataGridViewRow r in TeldgView.Rows)
                    {
                        if (!r.IsNewRow)
                        {
                            int    ItemID             = ItemsMgmt.SelectItemIDByBarcode(TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString());
                            double OldAvgUnitCost     = BillDetailedMgmt.SelectOldAvgUnitCostByID(ItemID, int.Parse(aBillGeneralRow["Number"].ToString()));
                            double ReturnQty          = double.Parse(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString());
                            double CurrentAvgUnitCost = ItemsMgmt.SelectItemCostByBarcode(TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString());
                            double CurrentAvaQty      = ItemsMgmt.SelectItemQtyByID(ItemID);
                            double NewAvgUnitCost     = CurrentAvgUnitCost;
                            if ((ReturnQty + CurrentAvaQty) != 0) //to avoid division by zero
                            {
                                NewAvgUnitCost = ((CurrentAvgUnitCost * CurrentAvaQty) + (ReturnQty * OldAvgUnitCost)) / (ReturnQty + CurrentAvaQty);
                            }
                            CostLoss += (NewAvgUnitCost - OldAvgUnitCost) * BillDetailedMgmt.SelectAllItemsSoldAfterBillNumber(ItemID, int.Parse(aBillGeneralRow["Number"].ToString()));
                            ItemsMgmt.UpdateItemQtyandAvgUnitCostByID(ItemID, (ReturnQty + CurrentAvaQty), NewAvgUnitCost);
                            BillDetailedMgmt.MakeItemAsRevised(int.Parse(aBillGeneralRow["Number"].ToString()), ItemID);
                        }
                    }
                    //Now we should mark the bill general as reversed
                    if (!BillGeneralMgmt.UpdateBillToRevised(SharedFunctions.ReturnLoggedUserName(), DateTime.Now.ToShortDateString(), int.Parse(aBillGeneralRow["Number"].ToString()), CostLoss))
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DB-ERROR-EditBill-ReviseBillBtn_Click] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }

                    MessageBox.Show(MsgTxt.ReversedSuccessfullyTxt, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show(MsgTxt.AlreadyReversedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-ReviseBillBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                throw;
            }
        }
コード例 #4
0
ファイル: AdjustItemsFrm.cs プロジェクト: SariSultan/RMS
        private bool ExportToPDF(int GeneralNumber)
        {
            try
            {
                List<DataTable> aDataTableList = new List<DataTable>();
                DataTable aDataTable1 = new DataTable();
                aDataTable1.Columns.Add("[border=true1]" + "<th width=15%>" + ReportsText.BarcodeRepTxt);
                aDataTable1.Columns.Add("<th width=20%>" + ReportsText.DescriptionRepTxt);
                aDataTable1.Columns.Add("<th width=9%>" + ReportsText.AvgCostRepTxt);
                aDataTable1.Columns.Add("<th width=9%>" + ReportsText.AvaQtyRepTxt);
                aDataTable1.Columns.Add(ReportsText.PhysicalCountRepTxt);
                aDataTable1.Columns.Add(ReportsText.DifferencesRepTxt);
                aDataTable1.Columns.Add(ReportsText.DifferenceValueRepTxt);

                double TotalPositive = 0.00, TotalNegative = 0.00, ParsingTester = 0.00; ;
                foreach (DataRow aRow in aItemsTable.Rows)
                {
                    if (double.Parse(aRow["DifferencesColumn"].ToString()) == 0)
                    {
                        if (ACTIVE_MODE == AdjustItemsFrmModes.EDIT_MODE)
                        {
                            AdjustInventoryDetailedMgmt.DeleteDetailedEntries(GeneralNumber,int.Parse(aRow["ID"].ToString()));
                        }

                        continue;
                    }
                    DataRow aToAddRow = aDataTable1.Rows.Add();
                    if (ACTIVE_MODE==AdjustItemsFrmModes.ADDING_MODE)
                    {
                        aToAddRow[0] = aRow["Barcode"];
                        aToAddRow[1] = aRow["Description"];
                        aToAddRow[2] = Math.Round(double.Parse(aRow["AvgUnitCost"].ToString()), 3);
                        aToAddRow[3] = Math.Round(double.Parse(aRow["Qty"].ToString()), 3);
                        aToAddRow[4] = aRow["PhysicalCountColumn"];
                        aToAddRow[5] = aRow["DifferencesColumn"];
                        ParsingTester = double.Parse(aRow["DiffValueColumn"].ToString());
                        aToAddRow[6] = ParsingTester;  
                    }
                    else if (ACTIVE_MODE == AdjustItemsFrmModes.EDIT_MODE)
                    {
                        aToAddRow[0] = ReportsHelper.FindData(AllItemsTable, "ID", "Barcode", aRow["ItemID"].ToString());
                        aToAddRow[1] = ReportsHelper.FindData(AllItemsTable, "ID", "Description", aRow["ItemID"].ToString());
                        aToAddRow[2] = Math.Round(double.Parse(ReportsHelper.FindData(AllItemsTable, "ID", "AvgUnitCost", aRow["ItemID"].ToString())), 3);
                        aToAddRow[3] = Math.Round(double.Parse(ReportsHelper.FindData(AllItemsTable, "ID", "Qty", aRow["ItemID"].ToString())), 3);
                        aToAddRow[4] = aRow["PhysicalCountColumn"];
                        aToAddRow[5] = aRow["DifferencesColumn"];
                        ParsingTester = double.Parse(aRow["DiffValueColumn"].ToString());
                        aToAddRow[6] = ParsingTester; 
                    }
                    
                    if (ParsingTester > 0)
                    {
                        TotalPositive += ParsingTester;
                    }
                    else
                    {
                        TotalNegative += ParsingTester;
                    }
                }

                if (aDataTable1.Rows.Count == 0)
                {
                    DataTable aEmptyTable = new DataTable();
                    aEmptyTable.Columns.Add("INVENTORY STOCK AVAILABLE QTY MATCHES 100% THE PHYSICAL COUNT");
                    aDataTableList.Add(aEmptyTable);
                }
                else
                {

                    aDataTableList.Add(aDataTable1);
                    DataRow NetRow = aDataTable1.Rows.Add();
                    string EmptyNoborderRow = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + ReportsHelper.MANUAL_TD_END;
                    NetRow[0] = EmptyNoborderRow;
                    NetRow[1] = EmptyNoborderRow;
                    NetRow[2] = EmptyNoborderRow;
                    NetRow[3] = EmptyNoborderRow;
                    NetRow[4] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + ReportsText.TotalRepTxt + ReportsHelper.MANUAL_TD_END;
                    NetRow[5] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + ReportsText.PosAdjValueRepTxt + ReportsHelper.MANUAL_TD_END;
                    NetRow[6] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + TotalPositive + ReportsHelper.MANUAL_TD_END;
                    NetRow = aDataTable1.Rows.Add();
                    NetRow[0] = EmptyNoborderRow;
                    NetRow[1] = EmptyNoborderRow;
                    NetRow[2] = EmptyNoborderRow;
                    NetRow[3] = EmptyNoborderRow;
                    NetRow[4] = EmptyNoborderRow;
                    NetRow[5] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + ReportsText.NegAdjValueRepTxt + ReportsHelper.MANUAL_TD_END;
                    NetRow[6] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + TotalNegative + ReportsHelper.MANUAL_TD_END;
                    NetRow = aDataTable1.Rows.Add();
                    NetRow[0] = EmptyNoborderRow;
                    NetRow[1] = EmptyNoborderRow;
                    NetRow[2] = EmptyNoborderRow;
                    NetRow[3] = EmptyNoborderRow;
                    NetRow[4] = EmptyNoborderRow;
                    NetRow[5] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + "<b>" + ReportsText.NetValueRepTxt + "<b>" + ReportsHelper.MANUAL_TD_END;
                    NetRow[6] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + (TotalNegative + TotalPositive) + ReportsHelper.MANUAL_TD_END;

                }
                List<string> aStringList = ReportsHelper.ImportReportHeader(0, 1);
                List<string> aFooterList = ReportsHelper.ImportReportHeader(1, 1);

                aStringList.Add(SharedVariables.Line_Solid_10px_Black);
              
                if (ACTIVE_MODE==AdjustItemsFrmModes.ADDING_MODE)
                {
                    aStringList.Add(ReportsNames.InventoryStockAdjustRepName);
                    aStringList.Add("<h2>" + ReportsText.PrintedOnrepTxt + " " + DateTime.Now.ToShortDateString() + "&nbsp;&nbsp;" + DateTime.Now.ToShortTimeString() + "</h2>");
                    aStringList.Add("<h2> " + ReportsText.PrintedByrepTxt + ":&nbsp;&nbsp;" + SharedFunctions.ReturnLoggedUserName() + "</h2>");
                }
                else
                {
                    aStringList.Add("Update "+ReportsNames.InventoryStockAdjustRepName );
                    aStringList.Add("<h2>" + ReceiptText.RctTxtOrgDate + " " +DateTime.Parse( aAdjustGeneralList.Rows[0]["Date"].ToString()).ToShortDateString() + "</h2>");
                    aStringList.Add("<h2> " + ReceiptText.RctTxtOrgTeller + ":&nbsp;&nbsp;" +aUserRow["UserName"].ToString() + "</h2>");

                    aStringList.Add("<h2>" + ReceiptText.RctTxtReprintedOn + " " + DateTime.Now.ToShortDateString() + "&nbsp;&nbsp;" + DateTime.Now.ToShortTimeString() + "</h2>");
                    aStringList.Add("<h2> " + ReceiptText.RctTxtReprintedBy + ":&nbsp;&nbsp;" + SharedFunctions.ReturnLoggedUserName() + "</h2>");
                }

                aStringList.Add(ReceiptText.RctTxtInvoiceNum + ":&nbsp; " + GeneralNumber);
                aStringList.Add(SharedVariables.Line_Solid_10px_Black);

                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, false, false, !XlsChkBox.Checked, ReportsHelper.TempPDFOutputPath, XlsChkBox.Checked, ReportsHelper.TempOutputPathExcel, false, false);

                if (XlsChkBox.Checked)
                {
                    Process.Start(ReportsHelper.TempOutputPathExcel);
                }
                else
                {
                    Process.Start(ReportsHelper.TempPDFOutputPath);
                }
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n Exception: IN[AdjustItemsFrm:ExportToPDF [EXCEPTION IS]] \n" + ex.Message, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

        }
コード例 #5
0
 private DisposalGeneral FillDisposalGeneral()
 {
     try
     {
         DisposalGeneral aDisposalGeneral = new DisposalGeneral();
         aDisposalGeneral.Disposal_General_Date      = DateTime.Now.ToShortDateString();
         aDisposalGeneral.Disposal_General_Time      = DateTime.Now.ToShortTimeString();
         aDisposalGeneral.Disposal_General_Reason    = int.Parse(DisposalReasonComboBox.SelectedValue.ToString());
         aDisposalGeneral.Disposal_General_Number    = GetNextDisposalNumber();
         aDisposalGeneral.Disposal_General_TotalCost = double.Parse(TotalTxtBox.Text);
         aDisposalGeneral.Disposal_General_TotalTax  = double.Parse(TaxTxtBox.Text);
         aDisposalGeneral.Disposal_General_Comments  = CommentsTxtBox.Text;
         aDisposalGeneral.Disposal_General_TellerID  = Convert.ToInt32(UsersMgmt.SelectUserIDByUserName(SharedFunctions.ReturnLoggedUserName()).ToString()); //for now
         return(aDisposalGeneral);
     }
     catch
     {
         return(null);
     }
 }
コード例 #6
0
        //To Make Size Always Normal For Non-Grid Forms

        private bool print_receipt()
        {
            try
            {
                List <DataTable> aDataTableList = new List <DataTable>();
                DataTable        aDataTable1    = new DataTable();
                aDataTable1.Columns.Add("[border=true1]" + ReceiptText.RctTxtToPayAmount);
                aDataTable1.Columns.Add(PaymentAmountTxtBox.Text);

                aDataTable1.Rows.Add();
                aDataTable1.Rows[0][0] = ReceiptText.RctTxtPayMethod;
                aDataTable1.Rows[0][1] = PaymentMethodCheckBox.Text;
                aDataTable1.Rows.Add();
                double OldCustomerAccountAmountParser = 0;
                if (double.TryParse(CustomerBalanceTxtBox.Text, out OldCustomerAccountAmountParser))
                {
                    aDataTable1.Rows[1][0] = ReceiptText.RctTxtOldBalance;
                    aDataTable1.Rows[1][1] = OldCustomerAccountAmountParser;
                    aDataTable1.Rows.Add();
                    aDataTable1.Rows[2][0] = ReceiptText.RctTxtNewBalance;
                    aDataTable1.Rows[2][1] = OldCustomerAccountAmountParser + double.Parse(PaymentAmountTxtBox.Text);
                    if (double.TryParse(CurrentBalanceTxtBox.Text, out OldCustomerAccountAmountParser))
                    {
                        aDataTable1.Rows.Add();
                        aDataTable1.Rows[3][0] = ReceiptText.RctTxtCurrenctBalance;
                        aDataTable1.Rows[3][1] = OldCustomerAccountAmountParser.ToString();
                    }
                }

                aDataTableList.Add(aDataTable1);
                List <string> aStringList = ReportsHelper.ImportReportHeader(0, 0);
                List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 0);
                aStringList.Add(SharedVariables.Line_Solid_10px_Black);
                aStringList.Add(ReceiptName.RctNmsCustomerPay);
                aStringList.Add(ReceiptText.RctTxtDuplicate);

                if (aCustomerPaymentRowGlobal["IsRevised"].ToString() == "1")
                {
                    aStringList.Add("*** " + ReceiptText.RctTxtReversed + " ***");
                    aStringList.Add("<h2> " + ReceiptText.RctTxtReversedBy + ":&nbsp;&nbsp;" + RevisedBylbl.Text + "</h2>");
                    aStringList.Add("<h2> " + ReceiptText.RctTxtReversedOn + ":&nbsp;&nbsp;" + ReviseDatelbl.Text + "</h2>");
                }

                aStringList.Add("<h2>" + ReceiptText.RctTxtOrgDate + "/" + ReceiptText.RctTxtOrgTime + " " + DateLbl.Text + "&nbsp;&nbsp;" + TimeLbl.Text + "</h2>");
                aStringList.Add("<h2> " + ReceiptText.RctTxtOrgTeller + ":&nbsp;&nbsp;" + TellerLbl.Text + "</h2>");
                aStringList.Add("<h2>" + ReceiptText.RctTxtReprintedOn + " " + DateTime.Now.ToShortDateString() + "&nbsp;&nbsp;" + DateTime.Now.ToShortTimeString() + "</h2>");
                aStringList.Add("<h2> " + ReceiptText.RctTxtReprintedBy + ":&nbsp;&nbsp;" + SharedFunctions.ReturnLoggedUserName() + "</h2>");


                aStringList.Add(ReceiptText.RctTxtCustomer + ":&nbsp;&nbsp;" + CustomerNameTxtBox.Text);
                aStringList.Add(ReceiptText.RctTxtPaymentNum + ":&nbsp; " + PaymentNumberTxtBox.Text);
                aStringList.Add(SharedVariables.Line_Solid_10px_Black);
                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true);
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n Exception: IN[EditCustomerPayment:Print Receipt [EXCEPTION IS]] \n" + ex.Message, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
コード例 #7
0
ファイル: AdjustItemsFrm.cs プロジェクト: SariSultan/RMS
 private int AddAdjustGeneralEntry(DataTable aTable)
 {
     try
     {
         if (!ValidateAdjustTable(aTable))
         {
             return -1;
         }
         AdjustInventoryGeneral aAdjustGeneral = new AdjustInventoryGeneral();
         aAdjustGeneral.Number = AdjustInventoryGeneralMgmt.NextBillNumber();
         aAdjustGeneral.TellerID = Convert.ToInt32(UsersMgmt.SelectUserIDByUserName(SharedFunctions.ReturnLoggedUserName()).ToString());
         aAdjustGeneral.Date = DateTime.Now.ToShortDateString();
         aAdjustGeneral.IsChecked = 0;
         if (AdjustInventoryGeneralMgmt.AddAdjustGeneralItem(aAdjustGeneral))
         {
             return aAdjustGeneral.Number;
         }
         else
         {
             return aAdjustGeneral.Number;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("NOT ADDED \n ERROR IN ADJUSTITEMSFRM: FUNCTION:AddAdjustToDataBase {EXCEPTION }" + ex.ToString(), MsgTxt.UnexpectedError, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return -1;
     }
 }
コード例 #8
0
        private void RevisePaymentBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (aCustomerPaymentRowGlobal["IsRevised"].ToString() == "0")
                {
                    string  RevisedBy     = SharedFunctions.ReturnLoggedUserName();
                    string  ReviseDate    = DateTime.Now.ToShortDateString();
                    string  ReviseTime    = DateTime.Now.ToShortTimeString();
                    int     PaymentNumber = int.Parse(aCustomerPaymentRowGlobal["PaymentNumber"].ToString());
                    DataRow aMethodRow    = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(aCustomerPaymentRowGlobal["PaymentMethodID"].ToString()));
                    if (aMethodRow == null)
                    {
                        // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-SelectMethodRowByID Returned Null] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw new Exception("EditCustomerPayment-SelectMethodRowByID Returned Null");
                    }
                    if (!CustomersPaymentsMgmt.UpdatePaymentToRevised(RevisedBy, ReviseDate, ReviseTime, PaymentNumber))
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DB-ERROR-EditcustomerPayment-RevisePaymentBtn_Click-FUNC:UpdatePaymentToRevised] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }

                    if (aMethodRow["IsCheck"].ToString() == "1")
                    {
                        ChecksMgmt.MakeCheckRevised(int.Parse(aCustomerPaymentRowGlobal["CheckNumber"].ToString()), DateTime.Now.ToShortDateString());
                    }



                    double Amount        = double.Parse(aCustomerPaymentRowGlobal["Amount"].ToString());
                    double CurrentAmount = double.Parse(aCustomerAccount["Amount"].ToString());
                    int    AccountID     = int.Parse(aCustomerAccount["ID"].ToString());
                    double NewAmount     = CurrentAmount + Amount;

                    if (!CustomersAccountsMgmt.UpdateAccountAmountByAccountID(AccountID, NewAmount))
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DB-ERROR-EditcustomerPayment-RevisePaymentBtn_Click-FUNC:UpdateAccountAmountByAccountID] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }
                    else
                    {
                        //int.Parse(AccountComboBox.SelectedValue.ToString());
                        int     MyAccountID = int.Parse(aCustomerPaymentRowGlobal["AccountID"].ToString());
                        DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(MyAccountID);
                        double  OldAmount   = double.Parse(aAccountRow["Amount"].ToString());
                        double  MyNewAmount = OldAmount - Amount;
                        AccountsMgmt.UpdateAccountAmountByAccountID(MyAccountID, MyNewAmount);
                    }

                    //Mark the check (if any) as revised
                    MessageBox.Show(MsgTxt.ReversedSuccessfullyTxt, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show(MsgTxt.AlreadyReversedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditcustomerPayment-RevisePaymentBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                throw;
            }
        }
コード例 #9
0
ファイル: EditVendorPayments.cs プロジェクト: SariSultan/RMS
 private void EditVendorPayments_Load(object sender, EventArgs e)
 {
     CurrentUserLbl.Text = SharedFunctions.ReturnLoggedUserName();
 }
コード例 #10
0
        private bool print_receipt()
        {
            try
            {
                List <DataTable> aDataTableList = new List <DataTable>();
                DataTable        aDataTable1    = new DataTable();
                aDataTable1.Columns.Add("[border=true1]" + ReceiptText.RctTxtToPayAmount);
                aDataTable1.Columns.Add(PaymentAmountTxtBox.Text);

                aDataTable1.Rows.Add();
                aDataTable1.Rows[0][0] = ReceiptText.RctTxtPayMethod;
                aDataTable1.Rows[0][1] = PaymentMethodCheckBox.Text;
                aDataTable1.Rows.Add();
                double OldCustomerAccountAmountParser = 0;
                if (double.TryParse(CustomerBalanceTxtBox.Text, out OldCustomerAccountAmountParser))
                {
                    aDataTable1.Rows[1][0] = ReceiptText.RctTxtOldBalance;
                    aDataTable1.Rows[1][1] = OldCustomerAccountAmountParser;
                    aDataTable1.Rows.Add();
                    aDataTable1.Rows[2][0] = ReceiptText.RctTxtNewBalance;
                    aDataTable1.Rows[2][1] = OldCustomerAccountAmountParser - double.Parse(PaymentAmountTxtBox.Text);
                }

                aDataTableList.Add(aDataTable1);
                List <string> aStringList = ReportsHelper.ImportReportHeader(0, 0);
                List <string> aFooterList = ReportsHelper.ImportReportHeader(1, 0);
                aStringList.Add(SharedVariables.Line_Solid_10px_Black);
                aStringList.Add(ReceiptName.RctNmsCustomerPay);
                aStringList.Add("<h2>" + ReceiptText.RctTxtDate + "/" + ReceiptText.RctTxtTime + " " + DateTime.Now.ToShortDateString() + "&nbsp;&nbsp;" + DateTime.Now.ToShortTimeString() + "</h2>");
                aStringList.Add("<h2> " + ReceiptText.RctTxtTeller + ":&nbsp;&nbsp;" + SharedFunctions.ReturnLoggedUserName() + "</h2>");
                aStringList.Add(ReceiptText.RctTxtCustomer + ":&nbsp;&nbsp;" + CustomerNameComboBox.Text);
                aStringList.Add(ReceiptText.RctTxtPaymentNum + ":&nbsp; " + PaymentNumberTxtBox.Text);
                aStringList.Add(SharedVariables.Line_Solid_10px_Black);
                // PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true);
                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, !PrintingThermalA4ChkBox.Checked, !PrintingThermalA4ChkBox.Checked, PrintingThermalA4ChkBox.Checked, ReportsHelper.TempOutputPath + ".pdf", false, "", false, PrintingThermalA4ChkBox.Checked);
                if (PrintingThermalA4ChkBox.Checked)
                {
                    Process.Start(ReportsHelper.TempPDFOutputPath);
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n Exception: IN[AddCustomerPayment:Print Receipt [EXCEPTION IS]] \n" + ex.Message, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
コード例 #11
0
        private bool AddPayment()
        {
            semaphore = true;
            int    NextCheckNumber = -1;
            double Amount          = 0;

            try
            {
                if (CustomerDoNotHaveAccount)
                {
                    MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n 1)" + MsgTxt.CustomerTxt + "\n2)" + MsgTxt.ValidAccountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    semaphore = false; return(false);
                }
                else
                {
                    if (!double.TryParse(PaymentAmountTxtBox.Text, out Amount) || PaymentAmountTxtBox.Text == string.Empty)
                    {
                        MessageBox.Show(MsgTxt.PleaseSelectCorrectAmountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        PaymentAmountTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        return(false);
                    }
                    else if (Amount == 0)
                    {
                        MessageBox.Show(MsgTxt.PleaseSelectCorrectAmountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        PaymentAmountTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        return(false);
                    }
                    else
                    {
                        PaymentAmountTxtBox.BackColor = PaymentAmountTxtBoxCOLOR;
                        //This is Added To Take The New Value
                        //انه لو صارت حركة بيع في اثناء التعديل
                        DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString()));
                        aCusomerAccountRow = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID);
                        Balance            = Double.Parse(aCusomerAccountRow["Amount"].ToString());

                        aCustomerPayment = new CustomersPayments();
                        int PaymentNumber = CustomersPaymentsMgmt.NextPaymentNumber();
                        if (PaymentNumber == 0)//ERROR PAYMENT NUMBER ZERO
                        {
                            MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [Payment Number = 0] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            semaphore = false;
                            this.Close();
                            return(false);
                        }
                        aCustomerPayment.Customer_Payment_PaymentNumber = PaymentNumber;
                        aCustomerPayment.Customer_Payment_CustomerID    = CustomerID;
                        aCustomerPayment.Customer_Payment_Date          = DateTime.Now.ToShortDateString();
                        aCustomerPayment.Customer_Payment_Time          = DateTime.Now.ToShortTimeString();

                        int TellerID = UsersMgmt.SelectUserIDByUserName(SharedFunctions.ReturnLoggedUserName());
                        if (TellerID == 0)
                        {
                            MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [TellerID = 0] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);

                            semaphore = false;
                            this.Close();
                            return(false);
                        }
                        aCustomerPayment.Customer_Payment_TellerID  = TellerID;
                        aCustomerPayment.Customer_Payment_OldAmount = Balance;
                        aCustomerPayment.Customer_Payment_Amount    = Amount;
                        aCustomerPayment.Customer_Payment_Comments  = CommentsTxtBox.Text;
                        aCustomerPayment.PaymentMethodID            = int.Parse(PaymentMethodCheckBox.SelectedValue.ToString());
                        aCustomerPayment.AccountID = int.Parse(AccountComboBox.SelectedValue.ToString());
                        Checks aCheck = new Checks();
                        if (aMethodRow["IsCash"].ToString() == "1")
                        {
                            aCustomerPayment.IsCreditCard   = 0;
                            aCustomerPayment.CreditCardInfo = "NOT-CREDIT";
                            if (!CustomersPaymentsMgmt.AddCustomerPayment(aCustomerPayment))
                            {
                                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error:CANNOT ADD PAYMENT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                semaphore = false;
                                this.Close();
                                return(false);
                            }

                            int    CusAccountID = int.Parse(aCusomerAccountRow["ID"].ToString());
                            double NewAmount    = aCustomerPayment.Customer_Payment_OldAmount - aCustomerPayment.Customer_Payment_Amount;
                            if (!CustomersAccountsMgmt.UpdateAccountAmountByAccountID(CusAccountID, NewAmount))
                            {
                                CustomersPaymentsMgmt.DeleteCustomerPayment(aCustomerPayment);
                                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error:CANNOT UPDATE ACCOUNT AMOUNT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                semaphore = false;
                                this.Close();
                                return(false);
                            }
                            MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            semaphore = false;

                            return(true);
                        }
                        else if (aMethodRow["IsCredit"].ToString() == "1")//-----------------------------------------------------------------------------
                        {
                            if (CreditCardInfoTxtBox.Text.Trim() != "")
                            {
                                aCustomerPayment.IsCreditCard   = 1;
                                aCustomerPayment.CreditCardInfo = CreditCardInfoTxtBox.Text;
                                if (!CustomersPaymentsMgmt.AddCustomerPayment(aCustomerPayment))
                                {
                                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error:CANNOT ADD PAYMENT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    this.Close();
                                    return(false);
                                }
                                int    CusAccountID = int.Parse(aCusomerAccountRow["ID"].ToString());
                                double NewAmount    = aCustomerPayment.Customer_Payment_OldAmount - aCustomerPayment.Customer_Payment_Amount;
                                if (!CustomersAccountsMgmt.UpdateAccountAmountByAccountID(CusAccountID, NewAmount))
                                {
                                    CustomersPaymentsMgmt.DeleteCustomerPayment(aCustomerPayment);
                                    MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error:CANNOT UPDATE ACCOUNT AMOUNT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    this.Close();
                                    return(false);
                                }

                                MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                semaphore = false;
                                return(true);
                            }
                            else
                            {
                                MessageBox.Show(MsgTxt.PleaseAddCreditCardInfoTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                CreditCardInfoTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                semaphore = false;
                                return(true);
                            }
                        }
                        else //its cheque----------------------------------------------------------------------------------
                        {
                            if (HolderNameTxtBox.Text.Trim() != "")
                            {
                                aCheck.Chekcs_HolderName = HolderNameTxtBox.Text;
                            }
                            else
                            {
                                MessageBox.Show(MsgTxt.CheckHolderNameTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                semaphore = false;
                                HolderNameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                return(false);
                            }

                            aCustomerPayment.IsCreditCard   = 0;
                            aCustomerPayment.CreditCardInfo = "NOT-CREDIT";
                            //its check
                            NextCheckNumber = ChecksMgmt.NextCheckNumber();
                            if (NextCheckNumber == 0) //ERRO IN CHEQUES
                            {
                                MessageBox.Show("ERROR IN CHEQUE");
                                semaphore = false;
                                return(false);
                            }
                            aCustomerPayment.CheckNumber = NextCheckNumber;

                            if (!CustomersPaymentsMgmt.AddCustomerPayment(aCustomerPayment))
                            {
                                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error: CANNOT ADD PAYMENT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                semaphore = false;
                                this.Close();
                                return(false);
                            }
                            aCheck.Chekcs_PaymentDate       = CheckDatePicker.Value.ToShortDateString();
                            aCheck.Chekcs_IsBill            = 0;
                            aCheck.Chekcs_IsPurchaseVoucher = 0;
                            aCheck.Chekcs_AccountID         = 0;
                            aCheck.Chekcs_Comments          = CheckCommentsTxtBox.Text;
                            aCheck.Chekcs_Amount            = aCustomerPayment.Customer_Payment_Amount;
                            aCheck.Chekcs_IsPaid            = 0;
                            aCheck.CheckNumber                  = NextCheckNumber;
                            aCheck.AddingDate                   = DateTime.Now.ToShortDateString();
                            aCheck.Chekcs_PaymentDate           = CheckDatePicker.Text;
                            aCheck.Chekcs_IsVendorPayment       = 0;
                            aCheck.Chekcs_IsCustomerPayment     = 1;
                            aCheck.Chekcs_CustomerPaymentNumber = aCustomerPayment.Customer_Payment_PaymentNumber;

                            if (!ChecksMgmt.InsertCheck(aCheck))
                            {
                                CustomersPaymentsMgmt.DeleteCustomerPayment(aCustomerPayment);
                                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error: CANNOT ADD CHECK] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                semaphore = false;
                                return(true);
                            }

                            int    CusAccountID = int.Parse(aCusomerAccountRow["ID"].ToString());
                            double NewAmount    = aCustomerPayment.Customer_Payment_OldAmount - aCustomerPayment.Customer_Payment_Amount;

                            if (!CustomersAccountsMgmt.UpdateAccountAmountByAccountID(CusAccountID, NewAmount))
                            {
                                ChecksMgmt.DeleteCheckByCheckNumber(aCheck.CheckNumber);
                                CustomersPaymentsMgmt.DeleteCustomerPayment(aCustomerPayment);
                                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error:CANNOT UPDATE ACCOUNT AMOUNT] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                semaphore = false;
                                this.Close();
                                return(false);
                            }

                            MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            semaphore = false;

                            return(true);
                        } //end of cheque
                    }
                }
            }

            catch (Exception ex)
            {
                semaphore = false;
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddPaymentBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            return(false);
        }
コード例 #12
0
        private bool AddPayment()
        {
            try
            {
                semaphore = true;
                int    NextCheckNumber = -1;
                double Amount          = 0;
                if (VendorDoNotHaveAccount || AccountNotJOD)
                {
                    MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n 1)" + MsgTxt.VendorTxt + "\n2)" + MsgTxt.ValidAccountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    semaphore = false; return(false);
                }
                else
                {
                    if (!double.TryParse(PaymentAmountTxtBox.Text, out Amount))
                    {
                        MessageBox.Show(MsgTxt.PleaseSelectCorrectAmountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        PaymentAmountTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        return(false);
                    }
                    else if (Amount == 0)
                    {
                        MessageBox.Show(MsgTxt.PleaseSelectCorrectAmountTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        PaymentAmountTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        return(false);
                    }
                    else
                    {
                        PaymentAmountTxtBox.BackColor = PaymentAmountTxtBoxCOLOR;

                        DataRow aMethodRow = PaymentMethodMgmt.SelectMethodRowByID(int.Parse(PaymentMethodCheckBox.SelectedValue.ToString()));
                        if (aMethodRow == null)
                        {
                            throw new Exception("aMethodRow==null");
                        }
                        aVendorAccountRow = VendorsAccountsMgmt.SelectVendorAccountRowByVendorID(VendorID);

                        Balance = Double.Parse(aVendorAccountRow["Amount"].ToString());

                        aVendorPayment = new VendorsPayments();
                        int PaymentNumber = VendorsPaymentsMgmt.NextPaymentNumber();
                        aVendorPayment.Vendor_Payment_PaymentNumber = PaymentNumber;
                        aVendorPayment.Vendor_Payment_VendorID      = VendorID;
                        aVendorPayment.Vendor_Payment_Date          = DateTime.Now.ToShortDateString();
                        aVendorPayment.Vendor_Payment_Time          = DateTime.Now.ToShortTimeString();
                        int TellerID = UsersMgmt.SelectUserIDByUserName(SharedFunctions.ReturnLoggedUserName());
                        aVendorPayment.Vendor_Payment_TellerID  = TellerID;
                        aVendorPayment.Vendor_Payment_OldAmount = Balance;
                        aVendorPayment.PaymentMethodID          = int.Parse(PaymentMethodCheckBox.SelectedValue.ToString());
                        aVendorPayment.Vendor_Payment_Comments  = CommentsTxtBox.Text;
                        aVendorPayment.MyAccountID           = int.Parse(AccountComboBox.SelectedValue.ToString());
                        aVendorPayment.Vendor_Payment_Amount = double.Parse(PaymentAmountTxtBox.Text);
                        Checks aCheck = new Checks();
                        if (aMethodRow["IsCash"].ToString() == "1")
                        {
                            aVendorPayment.IsCreditCard   = 0;
                            aVendorPayment.CreditCardInfo = "NOT-CREDIT";
                            VendorsPaymentsMgmt.AddVendorPayment(aVendorPayment);
                            //IS REVISED AND IS CHECKED ADDED TO ZERO IN QUERY
                            int    VenAccountID = int.Parse(aVendorAccountRow["ID"].ToString());
                            double NewAmount    = Balance - aVendorPayment.Vendor_Payment_Amount;
                            VendorsAccountsMgmt.UpdateAccountAmountByAccountID(VenAccountID, NewAmount);
                            double MyOldAmount = AccountsMgmt.SelectAccountAmountByID(int.Parse(AccountComboBox.SelectedValue.ToString()));
                            AccountsMgmt.UpdateAccountAmountByAccountID(int.Parse(AccountComboBox.SelectedValue.ToString()), MyOldAmount - aVendorPayment.Vendor_Payment_Amount);
                        }
                        else if (aMethodRow["IsCredit"].ToString() == "1")
                        {
                            aVendorPayment.IsCreditCard   = 1;
                            aVendorPayment.CreditCardInfo = CreditCardInfoTxtBox.Text;
                            VendorsPaymentsMgmt.AddVendorPayment(aVendorPayment);
                            //IS REVISED AND IS CHECKED ADDED TO ZERO IN QUERY
                            int    VenAccountID = int.Parse(aVendorAccountRow["ID"].ToString());
                            double NewAmount    = Balance - aVendorPayment.Vendor_Payment_Amount;
                            VendorsAccountsMgmt.UpdateAccountAmountByAccountID(VenAccountID, NewAmount);
                            int     AccountID   = int.Parse(AccountComboBox.SelectedValue.ToString());
                            DataRow aAccountRow = AccountsMgmt.SelectAccountRowByID(AccountID);
                            double  OldAmount   = double.Parse(aAccountRow["Amount"].ToString());
                            double  NewAmount2  = OldAmount - aVendorPayment.Vendor_Payment_Amount;
                            AccountsMgmt.UpdateAccountAmountByAccountID(AccountID, NewAmount2);
                        }
                        else
                        {
                            aVendorPayment.IsCreditCard   = 0;
                            aVendorPayment.CreditCardInfo = "NOT-CREDIT";
                            NextCheckNumber            = ChecksMgmt.NextCheckNumber();
                            aVendorPayment.CheckNumber = NextCheckNumber;
                            VendorsPaymentsMgmt.AddVendorPayment(aVendorPayment);

                            aCheck.Chekcs_HolderName        = HolderNameTxtBox.Text;
                            aCheck.Chekcs_PaymentDate       = CheckDatePicker.Value.ToShortDateString();
                            aCheck.Chekcs_IsBill            = 0;
                            aCheck.Chekcs_IsPurchaseVoucher = 0;
                            aCheck.Chekcs_AccountID         = 0;
                            aCheck.Chekcs_Comments          = CheckCommentsTxtBox.Text;
                            aCheck.Chekcs_Amount            = aVendorPayment.Vendor_Payment_Amount;
                            aCheck.Chekcs_IsPaid            = 0;
                            aCheck.CheckNumber                = NextCheckNumber;
                            aCheck.AddingDate                 = DateTime.Now.ToShortDateString();
                            aCheck.Chekcs_PaymentDate         = CheckDatePicker.Text;
                            aCheck.Chekcs_IsVendorPayment     = 1;
                            aCheck.Chekcs_VendorPaymentNumber = aVendorPayment.Vendor_Payment_PaymentNumber;
                            aCheck.Chekcs_IsCustomerPayment   = 0;

                            if (!ChecksMgmt.InsertCheck(aCheck))
                            {
                                VendorsPaymentsMgmt.DeleteVendorPayment(aVendorPayment);
                                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error: CANNOT ADD CHECK] \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                semaphore = false;
                                //ReloadForm();
                                return(false);
                            }
                        }
                        MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        semaphore = false;
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                semaphore = false;
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddPaymentBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return(false);
            }
        }