Ejemplo n.º 1
0
 private bool UpdateAdjustDetailedEntry(DataTable aTable, int GeneralNumber)
 {
     try
     {
         AdjustInventoryDetailed aAdjustDetailed = new AdjustInventoryDetailed();
         foreach (DataRow aRow in aItemsTable.Rows)
         {
             aAdjustDetailed.Number = GeneralNumber;
             aAdjustDetailed.ItemID = int.Parse(aRow["ItemID"].ToString());
             aAdjustDetailed.OldQty = double.Parse(aRow["NewQty"].ToString());/* bug it should be updated to the next one*/
             aAdjustDetailed.NewQty = double.Parse(aRow["PhysicalCountColumn"].ToString());
             aAdjustDetailed.DifferenceQty = double.Parse(aRow["DifferencesColumn"].ToString());
             aAdjustDetailed.DifferenceValue = double.Parse(aRow["DiffValueColumn"].ToString());
             double CurrentQty = double.Parse(ReportsHelper.FindData(AllItemsTable,"ID","Qty",aRow["ItemID"].ToString()));
             if (AdjustInventoryDetailedMgmt.UpdateDetailedSingleEntry(aAdjustDetailed))
             {
                 if (!ItemsMgmt.UpdateItemQtyByID(aAdjustDetailed.ItemID, (CurrentQty - (aAdjustDetailed.OldQty - aAdjustDetailed.NewQty))))
                 {
                     return false;
                 }
                 continue;
             }
             else
             {
                 return false;
             }
         }
         return true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception in UpdateAdjustDetailedEntry {EXCEPTION}" + ex.ToString(), "PLEASE CONTACT CALCIUM", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
 }
Ejemplo n.º 2
0
        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;
            }

        }