Example #1
0
        public void AddDGView(DataTable aVoucherDataTable)
        {
            try
            {
                foreach (DataRow r in aVoucherDataTable.Rows)
                {
                    int     RowNum   = TeldgView.Rows.Add();
                    DataRow aItemRow = ItemsMgmt.SelectItemRowByID(int.Parse(aVoucherDataTable.Rows[RowNum]["ItemID"].ToString()));
                    TeldgView.Rows[RowNum].Cells["Barcode"].Value = aItemRow["Barcode"].ToString();

                    TeldgView.Rows[RowNum].Cells["Description"].Value  = aItemRow["Description"].ToString();
                    TeldgView.Rows[RowNum].Cells["Qty"].Value          = aVoucherDataTable.Rows[RowNum]["Qty"].ToString();
                    TeldgView.Rows[RowNum].Cells["DiscountPerc"].Value = aVoucherDataTable.Rows[RowNum]["Discount"].ToString();
                    TeldgView.Rows[RowNum].Cells["FreeItemsQty"].Value = aVoucherDataTable.Rows[RowNum]["FreeItemsQty"].ToString();
                    TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value = aVoucherDataTable.Rows[RowNum]["ItemCost"].ToString();
                    TeldgView.Rows[RowNum].Cells["PriceTotal"].Value   = double.Parse(aVoucherDataTable.Rows[RowNum]["Qty"].ToString()) * double.Parse(aVoucherDataTable.Rows[RowNum]["ItemCost"].ToString());
                    TeldgView.Rows[RowNum].Cells["Tax"].Value          = ItemTaxLevelMgmt.SelectItemTaxByID(int.Parse(aItemRow["TaxLevel"].ToString()));
                    TeldgView.Rows[RowNum].Cells["AvalQty"].Value      = aVoucherDataTable.Rows[RowNum]["OldAvaQty"].ToString();
                    TeldgView.Rows[RowNum].Cells["AvgUnitCost"].Value  = aVoucherDataTable.Rows[0]["OldAvgUnitCost"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditVoucher-AddDGView] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Example #2
0
 private void UpdateList()
 {
     try
     {
         DataTable aDT = ItemsMgmt.SelectAllTouchScreenItems();
         if (aDT != null)
         {
             if (aDT.Rows.Count > 0)
             {
                 foreach (DataRow aRow in aDT.Rows)
                 {
                     TeldgView.ClearSelection();
                     int RowNum = TeldgView.Rows.Add();
                     TeldgView.Rows[RowNum].Cells["Barcode"].Value      = aRow["Barcode"].ToString();
                     TeldgView.Rows[RowNum].Cells["Description"].Value  = aRow["Description"].ToString();
                     TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value = aRow["SellPrice"].ToString();
                     TeldgView.Rows[RowNum].Cells["AvalQty"].Value      = aRow["Qty"].ToString();
                     TeldgView.Rows[RowNum].Selected = true;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateList] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }
Example #3
0
 //[/BARCODE FUNCTIONS]
 private void UpdateCash()
 {
     SubtotalTemp = 0; TaxTemp = 0; Subtotal = 0; TotalTax = 0;
     if (!semaphore && !OnExit)
     {
         semaphore = true;
         foreach (DataGridViewRow r in TeldgView.Rows)
         {
             if (!r.IsNewRow && !OnExit)
             {
                 try
                 {   //PriceLevelSelection
                     DataRow aItemRow = ItemsMgmt.SelectItemRowByBarcode(TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString());
                     SubtotalTemp = Math.Round(double.Parse(TeldgView.Rows[r.Index].Cells["PriceTotal"].Value.ToString()), 3);
                     Subtotal    += SubtotalTemp;
                     TaxTemp      = double.Parse(TeldgView.Rows[r.Index].Cells["Tax"].Value.ToString());
                     TotalTax    += (TaxTemp / 100) * SubtotalTemp; //Net amount = (Selling Price - Sales Price)*Tax
                     //updates
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show("UPDATE CASH ERROR IN [DISPOSE ITEMS] Exception:" + ex.ToString());
                     return;
                 }
             }
         }
         TotalTxtBox.Text    = Math.Round(Subtotal + TotalTax, 2).ToString();
         Subtotal            = Math.Round(Subtotal, 2);
         SubtotalTxtBox.Text = Subtotal.ToString();
         TotalTax            = Math.Round(TotalTax, 3);
         TaxTxtBox.Text      = TotalTax.ToString();
         semaphore           = false;
     }
 }
Example #4
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;
     }
 }
Example #5
0
        public void InitializeWithGeneralNumber(int RefNumber)
        {
            SEMAPHORE = true;
            aAdjustGeneralList = AdjustInventoryGeneralMgmt.SelectAllAdjustsGeneral(RefNumber, string.Empty, string.Empty);
            aItemsTable = AdjustInventoryDetailedMgmt.SelectAllAdjustsDetailed(RefNumber, -1);
            AllItemsTable = ItemsMgmt.SelectAllItems();
            aUserRow = UsersMgmt.SelectUserInfoByID(int.Parse(aAdjustGeneralList.Rows[0]["TellerID"].ToString()));

            if (aItemsTable.Rows.Count > 0)
            {
                aItemsTable.Columns.Add("PhysicalCountColumn", typeof(double));
                aItemsTable.Columns.Add("DifferencesColumn", typeof(double));
                aItemsTable.Columns.Add("DiffValueColumn", typeof(double));

                page(1);
            }
            else
            {
                MatchLbl.Visible = true;
            }

            AdjDatePicker.Text = aAdjustGeneralList.Rows[0]["Date"].ToString();
            ReferenceNumberTxtBox.Text = aAdjustGeneralList.Rows[0]["Number"].ToString();
            SEMAPHORE = false;
        }
Example #6
0
        private bool AddDisposalGeneral()
        {
            if (TeldgView.Rows.Count > 0)
            {
                if (DisposalReasonComboBox.SelectedValue == null)
                {
                    MessageBox.Show(MsgTxt.PleaseSelectTxt + " " + MsgTxt.DisposalReasonTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return(false);
                }

                DisposalGeneral aDisposalGeneral = FillDisposalGeneral();
                if (aDisposalGeneral == null)
                {
                    MessageBox.Show(MsgTxt.UnexpectedError, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                if (!DisposalGeneralMgmt.InsertDisposal(aDisposalGeneral))
                {
                    return(false);
                }
                DisposalDetailed aDisposalDetailed = new DisposalDetailed();
                foreach (DataGridViewRow r in TeldgView.Rows)
                {
                    if (!r.IsNewRow)
                    {
                        aDisposalDetailed.Disposal_Detailed_ItemID          = ItemsMgmt.SelectItemIDByBarcode(TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString());
                        aDisposalDetailed.Disposal_Detailed_ItemDescription = TeldgView.Rows[r.Index].Cells["Description"].Value.ToString();
                        aDisposalDetailed.Disposal_Detailed_Date            = DateTime.Now.ToShortDateString();
                        double TestParser = 0;
                        if (double.TryParse(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString(), out TestParser))
                        {
                            aDisposalDetailed.Disposal_Detailed_Qty = TestParser;//double.Parse(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString());
                        }
                        else
                        {
                            TestParser = 1;
                        }
                        aDisposalDetailed.Disposal_Detailed_UnitCost      = double.Parse(TeldgView.Rows[r.Index].Cells["PricePerUnit"].Value.ToString());
                        aDisposalDetailed.Disposal_Detailed_TotalPerUnit  = double.Parse(TeldgView.Rows[r.Index].Cells["PriceTotal"].Value.ToString());
                        aDisposalDetailed.Disposal_Detailed_GeneralNumber = aDisposalGeneral.Disposal_General_Number;
                        DisposalDetailedMgmt.InsertDisposalItem(aDisposalDetailed);
                        string Barcode = TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString();
                        ItemsMgmt.UpdateItemQtyByBarcode(Barcode, ItemsMgmt.SelectItemQtyByBarcode(Barcode), (0 - TestParser));//0-qty wich is negative to be subtracted from orginnal
                    }
                }
                return(true);
            }
            else
            {
                MessageBox.Show(MsgTxt.NotItemsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(false);
            }
        }
Example #7
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();
                }
            }
        }
Example #8
0
 private void DeleteItemsBtn_Click(object sender, EventArgs e)
 {
     try
     {
         foreach (DataGridViewRow row in TeldgView.SelectedRows)
         {
             if (!row.IsNewRow)
             {
                 ItemsMgmt.MakeItemTouchScreen(row.Cells["Barcode"].Value.ToString(), false);
                 TeldgView.Rows.Remove(row);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DeleteItemsBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }
Example #9
0
        private bool AddItemUsingBarcode(string aBarcode)
        {
            try
            {
                if (!ItemsMgmt.IsItemTouchScreen(aBarcode))
                {
                    DataTable aItemTable = ItemsMgmt.SelectItemByBarCode(aBarcode);
                    if (aItemTable.Rows.Count == 1)
                    {
                        TeldgView.ClearSelection();
                        int RowNum = TeldgView.Rows.Add();
                        TeldgView.Rows[RowNum].Cells["Barcode"].Value      = aItemTable.Rows[0]["Barcode"].ToString();
                        TeldgView.Rows[RowNum].Cells["Description"].Value  = aItemTable.Rows[0]["Description"].ToString();
                        TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value = aItemTable.Rows[0]["SellPrice"].ToString();
                        TeldgView.Rows[RowNum].Cells["AvalQty"].Value      = aItemTable.Rows[0]["Qty"].ToString();
                        TeldgView.Rows[RowNum].Selected = true;
                        BarcodeTxtBox.Text = string.Empty;
                        ItemsMgmt.MakeItemTouchScreen(aBarcode, true);
                        // MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.UpdateSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(true);
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.ItemNotFoundTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        BarcodeTxtBox.Text = string.Empty;
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.AlreadyUsedTxt, MsgTxt.InformationCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddItemUsingBarcode] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return(false);

                throw;
            }
        }
Example #10
0
 private void ListItemsDgView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         DataRow aItemrow = ItemsMgmt.SelectItemRowByBarcode(ListItemsDgView.Rows[e.RowIndex].Cells["Barcode"].Value.ToString());
         if (aItemrow == null)
         {
             return;
         }
         EditItems aEditItems = new EditItems();
         aEditItems.Show();
         aEditItems.TopLevel = true;
         aEditItems.UpdateVariables(aItemrow);
     }
     catch (Exception ex)
     {
         MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [ListItems:ListItemsDgView_CellDoubleClick()] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }
Example #11
0
        private void ListItemsBtn_Click(object sender, EventArgs e)
        {
            if (ACTIVE_MODE == AdjustItemsFrmModes.ADDING_MODE)
            {
                aItemsTable = ItemsMgmt.SelectAllItems();
                aItemsTable.Columns.Add("PhysicalCountColumn", typeof(double));
                aItemsTable.Columns.Add("DifferencesColumn", typeof(double));
                aItemsTable.Columns.Add("DiffValueColumn", typeof(double));
                foreach (DataRow aRow in aItemsTable.Rows)/*validating sends error if it is not initialized*/
                {
                    if (aRow["PhysicalCountColumn"].ToString() == string.Empty) aRow["PhysicalCountColumn"] = aRow["Qty"].ToString();
                    if (aRow["DifferencesColumn"].ToString() == string.Empty) aRow["DifferencesColumn"] = "0.00";
                    if (aRow["DiffValueColumn"].ToString() == string.Empty) aRow["DiffValueColumn"] = "0.00";
                }

                AddItemsToDgview();
            }
            else if (ACTIVE_MODE == AdjustItemsFrmModes.EDIT_MODE)
            {
                /* The button will be hidden in this mode*/
            }
        }
Example #12
0
 public void AddDgView(DataTable aBillDataTable)
 {
     try
     {
         foreach (DataRow r in aBillDataTable.Rows)
         {
             RowNum = TeldgView.Rows.Add();
             TeldgView.Rows[RowNum].Cells["Barcode"].Value      = ItemsMgmt.SelectItemBarcodeByID(int.Parse(aBillDataTable.Rows[RowNum]["ItemID"].ToString()));
             TeldgView.Rows[RowNum].Cells["Description"].Value  = aBillDataTable.Rows[RowNum]["ItemDescription"].ToString();
             TeldgView.Rows[RowNum].Cells["Qty"].Value          = aBillDataTable.Rows[RowNum]["Qty"].ToString();
             TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value = aBillDataTable.Rows[RowNum]["SellPrice"].ToString();
             TeldgView.Rows[RowNum].Cells["PriceTotal"].Value   = double.Parse(aBillDataTable.Rows[RowNum]["TotalPerUnit"].ToString());
             TeldgView.Rows[RowNum].Cells["Tax"].Value          = ItemTaxLevelMgmt.SelectItemTaxByID(int.Parse(ItemsMgmt.SelectTaxLevelIDByID(int.Parse(aBillDataTable.Rows[RowNum]["ItemID"].ToString())))).ToString();
             TeldgView.Rows[RowNum].Cells["AvalQty"].Value      = aBillDataTable.Rows[RowNum]["OldAvaQty"].ToString();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [EditBill-AddDgView] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
     }
 }
Example #13
0
 private bool AddAdjustDetailedEntry(DataTable aTable, int GeneralNumber)
 {
     try
     {
         AdjustInventoryDetailed aAdjustDetailed = new AdjustInventoryDetailed();
         foreach (DataRow aRow in aItemsTable.Rows)
         {
             if (double.Parse(aRow["DifferencesColumn"].ToString()) == 0)
             {
                 continue;
             }
             aAdjustDetailed.Number = GeneralNumber;
             aAdjustDetailed.ItemID = int.Parse(aRow["ID"].ToString());
             aAdjustDetailed.OldQty = double.Parse(aRow["Qty"].ToString());
             aAdjustDetailed.NewQty = double.Parse(aRow["PhysicalCountColumn"].ToString());
             aAdjustDetailed.DifferenceQty = double.Parse(aRow["DifferencesColumn"].ToString());
             aAdjustDetailed.DifferenceValue = double.Parse(aRow["DiffValueColumn"].ToString());
             if (AdjustInventoryDetailedMgmt.AddAdjustDetailedItem(aAdjustDetailed))
             {
                 if (!ItemsMgmt.UpdateItemQtyByID(aAdjustDetailed.ItemID, aAdjustDetailed.NewQty))
                 {
                     return false;
                 }
                 continue;
             }
             else
             {
                 return false;
             }
         }
         return true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("Exception in AddAdjustDetailedEntry {EXCEPTION}" + ex.ToString(), "PLEASE CONTACT CALCIUM", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
 }
Example #14
0
        public static void IsTrialValidTellNow()
        {
            Nullable <int> NumberOfItems = ItemsMgmt.SelectNumberOfItems();

            if (NumberOfItems == null)
            {
                MessageBox.Show("ERROR 0x01 " + MsgTxt.DataBaseErrorTxt + " " + MsgTxt.PleaseCheckSQLServiceTxt, MsgTxt.DataBaseErrorTxt, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.ExitThread();
                Application.Exit();
            }
            else
            {
                NumberOfItemsInTheSystem = int.Parse(NumberOfItems.ToString());
                if (NumberOfItems < TrialNumberOfItems)
                {
                    __IsTrialValid = true;
                }
                else
                {
                    __IsTrialValid = false;
                }
            }
        }
Example #15
0
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            Items aaItem = new Items();

            aaItem.Item_Type        = (int)TypeComboBox.SelectedValue;
            aaItem.Item_Category    = (int)CategoryComboBox.SelectedValue;
            aaItem.Vendor           = (int)VendorComboBox.SelectedValue;
            aaItem.Item_Tax_Level   = (int)TaxLevelComboBox.SelectedValue;
            aaItem.Item_Barcode     = BarcodeTxtBox.Text;
            aaItem.Item_Description = DescriptionTxtBox.Text;
            aaItem.Avalable_Qty     = double.Parse(QtyTxtBox.Text);
            aaItem.Render_Point     = double.Parse(RenderPointTxtBox.Text);
            // aaItem.Entry_Date = DateTxtBox.Text;
            aaItem.Sell_Price    = double.Parse(SellPriceTxtBox.Text);
            aaItem.Avg_Unit_Cost = double.Parse(AvgCostTxtBox.Text);
            // aaItem.PriceLevelID = int.Parse(SaleTxtBox.Text);
            // aaItem.Item_ID = int.Parse(IDTxtBox.Text);
            try
            {
                if (!ItemsMgmt.IsItemExist(BarcodeTxtBox.Text) || BarcodeTxtBox.Text == BarcodeToEditTxtBox.Text)
                {
                    ItemsMgmt.UpdateItemByID(aaItem);
                    MessageBox.Show("DONE");
                    this.Dispose();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Barcode " + BarcodeTxtBox.Text + " Already Exist in the system");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #16
0
        public bool PrintPhysicalItemsStatus(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 = ItemsMgmt.SelectAllItems();

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

                DataTable ToPrintTable = new DataTable();
                ToPrintTable.Columns.Add("Barcode");
                ToPrintTable.Columns.Add("Description");
                ToPrintTable.Columns.Add("Ava.Qty");
                ToPrintTable.Columns.Add("Physical Count");

                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["Physical Count"] = "________";
                }

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

                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);

                aHeaderList.Add("<b><font size=4>" + Text.ReportsNames.PhysicalInvWorksheetRepNm + " </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);
            }
        }
Example #17
0
        private void WithoutBarcodeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (IsUpdating)
                {
                    return;
                }
                if (WithoutBarcodeComboBox.SelectedValue != null)
                {
                    aItemData = ItemsMgmt.SelectItemByBarCode(WithoutBarcodeComboBox.SelectedValue.ToString());
                }
                else
                {
                    return;
                }
                if (aItemData.Rows.Count > 0)
                {
                    IsUpdating = true;
                    UpdateItemBtn.Show();
                    TypeComboBox.Text     = ItemTypeMgmt.SelectItemTypeByID(int.Parse(aItemData.Rows[0]["Type"].ToString()));
                    CategoryComboBox.Text = ItemCategoryMgmt.SelectItemCategoryByID(int.Parse(aItemData.Rows[0]["Category"].ToString()));
                    VendorComboBox.Text   = VendorsMgmt.SelectVendorByID(int.Parse(aItemData.Rows[0]["Vendor"].ToString()));
                    TaxLevelComboBox.Text = ItemTaxLevelMgmt.SelectItemTaxByID(int.Parse(aItemData.Rows[0]["TaxLevel"].ToString()));

                    BarcodeTxtBox.Text      = aItemData.Rows[0]["Barcode"].ToString();
                    DescriptionTxtBox.Text  = aItemData.Rows[0]["Description"].ToString();
                    QtyTxtBox.Text          = aItemData.Rows[0]["Qty"].ToString();
                    RenderPointTxtBox.Text  = aItemData.Rows[0]["RenderPoint"].ToString();
                    DateAddedTxtBox.Text    = aItemData.Rows[0]["EntryDate"].ToString();
                    SellPriceTxtBox.Text    = aItemData.Rows[0]["SellPrice"].ToString();
                    AvgCostTxtBox.Text      = aItemData.Rows[0]["AvgUnitCost"].ToString();
                    AvailableQtyTxtBox.Text = aItemData.Rows[0]["OnHandQty"].ToString(); /*@SMS V01O changed*/
                    Pricing.Controls.Clear();
                    //ADDING PRICE LEVELS
                    int ItemID = int.Parse(aItemData.Rows[0]["ID"].ToString());
                    aPriceLevelsTable = PriceLevelsMgmt.SelectAll();

                    if (aPriceLevelsTable.Rows.Count > 0)
                    {
                        foreach (DataRow r in aPriceLevelsTable.Rows)
                        {
                            if (r["Name"].ToString() != "Standard")
                            {
                                Label aLabel = new Label();
                                aLabel.Text      = r["Name"].ToString();
                                aLabel.ForeColor = Color.Black;
                                TextBox   aTextBox           = new TextBox();
                                DataTable aSpecialPriceTable = SpecialPricesMgmt.SelectSpecialPricebyItemIDandPriceLevelID(ItemID, int.Parse(r["ID"].ToString()));
                                if (aSpecialPriceTable.Rows.Count > 0)
                                {
                                    aTextBox.Text = aSpecialPriceTable.Rows[0]["Price"].ToString();
                                }
                                else
                                {
                                    aTextBox.Text = SellPriceTxtBox.Text;
                                }

                                aTextBox.Name         = r["Name"].ToString();
                                aTextBox.TextChanged += new EventHandler(Calcium_RMS.Validators.TextBoxDoubleInputChange);
                                Pricing.Controls.Add(aLabel);
                                Pricing.Controls.Add(aTextBox);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.NotUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                TaxEnclodedChkBox.Checked = false;
                UpdateMargin();
                IsUpdating = false;
            }
            catch (Exception ex)
            {
                IsUpdating = false;
                MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[WithoutBarcodeComboBox_SelectedIndexChanged] \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Example #18
0
        private void UpdateItemBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validators.TxtBoxNotEmpty(BarcodeTxtBox.Text) || WithoutBarcodeChkBox.Checked)
                {
                    BarcodeTxtBox.BackColor = BarcodeTxtBoxBGColor;
                    double ParsingOutTester = 0;
                    if (Validators.TxtBoxNotEmpty(QtyTxtBox.Text) && double.TryParse(QtyTxtBox.Text, out ParsingOutTester))
                    {
                        QtyTxtBox.BackColor = QtyTxtBoxBGColor;
                        if (Validators.TxtBoxNotEmpty(RenderPointTxtBox.Text) && double.TryParse(RenderPointTxtBox.Text, out ParsingOutTester))
                        {
                            RenderPointTxtBox.BackColor = RenderTxtBoxBGColor;
                            if (Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                            {
                                DescriptionTxtBox.BackColor = DescriptionBGColor;
                                if (Validators.TxtBoxNotEmpty(SellPriceTxtBox.Text) && double.TryParse(SellPriceTxtBox.Text, out ParsingOutTester))
                                {
                                    SellPriceTxtBox.BackColor = SellPriceBGColor;
                                    if (Validators.TxtBoxNotEmpty(AvgCostTxtBox.Text) && double.TryParse(AvgCostTxtBox.Text, out ParsingOutTester))
                                    {
                                        AvgCostTxtBox.BackColor = AvgUnitCostBGColor;

                                        bool IsPriceLevelsEmpty = false;

                                        foreach (var tb in Pricing.Controls.OfType <TextBox>())
                                        {
                                            if (!Validators.TxtBoxNotEmpty(tb.Text) || !double.TryParse(tb.Text, out ParsingOutTester))
                                            {
                                                IsPriceLevelsEmpty = true;
                                                tb.BackColor       = SharedVariables.TxtBoxRequiredColor;
                                            }
                                            else
                                            {
                                                // tb.BackColor = Color.Black;
                                            }
                                        }
                                        if (IsPriceLevelsEmpty)
                                        {
                                            MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.PriceLevelsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                            return;
                                        }
                                        else
                                        {
                                            bool IsBarcodeUsed = false;
                                            //CHECK IF NEW BARCODE IS  NOT CHECKED
                                            string OldBarcode;
                                            if (!WithoutBarcodeChkBox.Checked)
                                            {
                                                IsBarcodeUsed = ItemsMgmt.IsItemExist(BarcodeTxtBox.Text);
                                                if (ByBarcDescChkBox.Checked)
                                                {
                                                    OldBarcode = BarcodeToEditTxtBox.Text;
                                                }
                                                else
                                                {
                                                    OldBarcode = ItemDescriptionComboBox.SelectedValue.ToString();
                                                }
                                            }
                                            else
                                            {
                                                OldBarcode = WithoutBarcodeComboBox.SelectedValue.ToString();
                                            }
                                            Items aItem = new Items();
                                            aItem.Item_Type      = (int)TypeComboBox.SelectedValue;
                                            aItem.Item_Category  = (int)CategoryComboBox.SelectedValue;
                                            aItem.Vendor         = (int)VendorComboBox.SelectedValue;
                                            aItem.Item_Tax_Level = (int)TaxLevelComboBox.SelectedValue;
                                            if (WithoutBarcodeChkBox.Checked)
                                            {
                                                aItem.Item_Barcode = WithoutBarcodeComboBox.SelectedValue.ToString();
                                            }
                                            else
                                            {
                                                //aItem.IsWithoutBarcode = 0;
                                                aItem.Item_Barcode = BarcodeTxtBox.Text;
                                            }
                                            aItem.Item_ID = ItemsMgmt.SelectItemIDByBarcode(OldBarcode);
                                            if (!IsBarcodeUsed || WithoutBarcodeChkBox.Checked || OldBarcode == aItem.Item_Barcode)
                                            {
                                                aItem.Item_Description = DescriptionTxtBox.Text;
                                                aItem.Avalable_Qty     = double.Parse(QtyTxtBox.Text);
                                                aItem.Render_Point     = double.Parse(RenderPointTxtBox.Text);
                                                // aItem.Entry_Date = DateTime.Now.ToShortDateString();

                                                double aSellPrice = double.Parse(SellPriceTxtBox.Text);
                                                double aUnitCost  = double.Parse(AvgCostTxtBox.Text);
                                                double aTax       = double.Parse(ItemTaxLevelMgmt.SelectItemTaxByID(aItem.Item_Tax_Level));

                                                if (TaxEnclodedChkBox.Checked)
                                                {
                                                    aItem.Sell_Price    = Math.Round(aSellPrice / ((aTax / 100) + 1), 4);
                                                    aItem.Avg_Unit_Cost = Math.Round(aUnitCost / ((aTax / 100) + 1), 4);
                                                }
                                                else
                                                {
                                                    aItem.Sell_Price    = aSellPrice;
                                                    aItem.Avg_Unit_Cost = aUnitCost;
                                                }
                                                ItemsMgmt.UpdateItemByID(aItem);
                                                int ItemID = aItem.Item_ID;
                                                foreach (var tb in Pricing.Controls.OfType <TextBox>())
                                                {
                                                    Nullable <int> PriceLevelID = PriceLevelsMgmt.SelectPriceLevelIDByName(tb.Name);
                                                    if (PriceLevelID != null)
                                                    {
                                                        double atbSellPrice = double.Parse(tb.Text);

                                                        if (TaxEnclodedChkBox.Checked)
                                                        {
                                                            atbSellPrice = Math.Round(atbSellPrice / ((aTax / 100) + 1), 4);
                                                        }

                                                        Nullable <int> IsAddSpecialPriceOK;
                                                        if (SpecialPricesMgmt.IsSpecialPriceExist(ItemID, (int)PriceLevelID) == true)//exist update
                                                        {
                                                            IsAddSpecialPriceOK = SpecialPricesMgmt.UpdatePriceLevel(ItemID, (int)PriceLevelID, atbSellPrice);
                                                        }
                                                        else if (SpecialPricesMgmt.IsSpecialPriceExist(ItemID, (int)PriceLevelID) == false)//not exist create new
                                                        {
                                                            IsAddSpecialPriceOK = SpecialPricesMgmt.AddSpecialPrice(ItemID, (int)PriceLevelID, atbSellPrice);
                                                        } //null database error
                                                        else
                                                        {
                                                            MessageBox.Show(MsgTxt.UnexpectedError + "DataBase: SpecialPricesMgmt.AddSpecialPrice", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                            return;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        MessageBox.Show("UNEXPECTED ERROR !!ITEM ADDED SUCCESSFULY, NOT PRICE LEVELS ADDED " + "\n" + "PLEASE ADD PRICE LEVELS MANUALLY FROM EDIT ITEM PAGE", "PRICE LEVEL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                        throw new System.ArgumentException("Parameter cannot be null", "original");
                                                    }
                                                }
                                                MessageBox.Show(MsgTxt.UpdateSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                            }
                                            else
                                            {
                                                MessageBox.Show(MsgTxt.BarcodeTxt + " " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                BarcodeTxtBox.Text = "";
                                            }
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.UnitCostTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        AvgCostTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                        AvgCostTxtBox.Focus();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.SellingPriceTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    SellPriceTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                    SellPriceTxtBox.Focus();
                                }
                            }
                            else
                            {
                                MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.DescriptionTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                DescriptionTxtBox.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.RenderPointTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            RenderPointTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                            RenderPointTxtBox.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.ValidQtyTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        QtyTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        QtyTxtBox.Focus();
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.BarcodeTxt + "\n2)" + MsgTxt.IfNotBarChkWithoutBarcodeTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    BarcodeTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                    BarcodeTxtBox.Focus();
                }
            }
            catch (Exception ex)
            {
                IsUpdating = false;
                MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[UpdateItemBtn_Click] \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                throw;
            }
        }
Example #19
0
        public static bool InventoryAdjustReport(int ReferenceNumber, bool TableBorder = false, bool Preview = true, bool PrintToThermal = false, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool colored = false)
        {
            bool      GenerateReportIs100Matched = false;
            DataTable InventoryGeneral           = AdjustInventoryGeneralMgmt.SelectAllAdjustsGeneral(ReferenceNumber, string.Empty, string.Empty);

            if (InventoryGeneral == null)
            {
                return(false);
            }
            if (InventoryGeneral.Rows.Count == 0)
            {
                return(false);
            }
            DataTable InventoryDetailedTable = AdjustInventoryDetailedMgmt.SelectAllAdjustsDetailed(ReferenceNumber, -1);

            if (InventoryDetailedTable == null)
            {
                GenerateReportIs100Matched = true;
            }
            if (InventoryDetailedTable.Rows.Count == 0)
            {
                GenerateReportIs100Matched = true;
            }

            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;;
            DataTable ItemsTable = ItemsMgmt.SelectAllItems();

            foreach (DataRow aRow in InventoryDetailedTable.Rows)
            {
                if (double.Parse(aRow["DifferenceQty"].ToString()) == 0)
                {
                    continue;
                }
                DataRow aToAddRow = aDataTable1.Rows.Add();
                aToAddRow[0]  = ReportsHelper.FindData(ItemsTable, "ID", "Barcode", aRow["ItemID"].ToString());
                aToAddRow[1]  = ReportsHelper.FindData(ItemsTable, "ID", "Description", aRow["ItemID"].ToString());
                aToAddRow[2]  = Math.Round(double.Parse(ReportsHelper.FindData(ItemsTable, "ID", "AvgUnitCost", aRow["ItemID"].ToString())), 3);
                aToAddRow[3]  = Math.Round(double.Parse(aRow["OldQty"].ToString()), 3);
                aToAddRow[4]  = aRow["NewQty"];
                aToAddRow[5]  = aRow["DifferenceQty"];
                ParsingTester = double.Parse(aRow["DifferenceValue"].ToString());
                aToAddRow[6]  = ParsingTester;
                if (ParsingTester > 0)
                {
                    TotalPositive += ParsingTester;
                }
                else
                {
                    TotalNegative += ParsingTester;
                }
            }

            if (aDataTable1.Rows.Count == 0 || GenerateReportIs100Matched)
            {
                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);
            aStringList.Add(ReportsNames.InventoryStockAdjustRepName);
            aStringList.Add("<h2>" + "Added On" + " " + InventoryGeneral.Rows[0]["Date"].ToString() + "</h2>");
            aStringList.Add("<h2> " + "Added By" + ":&nbsp;&nbsp;" + UsersMgmt.SelectUserNameByID(int.Parse(InventoryGeneral.Rows[0]["TellerID"].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; " + ReferenceNumber);
            aStringList.Add(SharedVariables.Line_Solid_10px_Black);

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

            else if (ExportToPdf)
            {
                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, true, ExportPath, false, "", colored);
                return(true);
            }
            else if (ExportToExcel)
            {
                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, PrintToThermal, false, false, "", true, ExportPath, colored);
                return(true);
            }
            else if (PrintToThermal)
            {
                PrintingManager.Instance.PrintTables(aDataTableList, aStringList, aFooterList, ReportsHelper.TempOutputPath, ReportsHelper.TempOutputPath, true, true, false, "", false, "", colored);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #20
0
        public bool InvValuationSummaryStatus(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 = ItemsMgmt.SelectAllItems();

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


                DataTable ToPrintTable = new DataTable();
                ToPrintTable.Columns.Add("Name");
                ToPrintTable.Columns.Add("Ava Qty");
                ToPrintTable.Columns.Add("Avg Cost");

                ToPrintTable.Columns.Add("Inventory Value");
                ToPrintTable.Columns.Add("% of Tot Inventory");

                ToPrintTable.Columns.Add("Selling Price");
                ToPrintTable.Columns.Add("Retail Value");
                ToPrintTable.Columns.Add("% of Tot Retail");

                double AvgCost = 0.00, AvaQty = 0.00, SellingPrice = 0.00;
                double TotalInvValue    = 0.00; /*this to be used in the second loop*/
                double TotalRetailValue = 0.00; /*this to be used in the second loop*/
                double TotalQty         = 0.00;
                foreach (DataRow r in ItemsDatatable.Rows)
                {
                    AvgCost      = double.Parse(r["AvgUnitCost"].ToString());
                    AvaQty       = double.Parse(r["Qty"].ToString());
                    SellingPrice = double.Parse(r["SellPrice"].ToString());

                    if (AvaQty <= 0)
                    {
                        continue;
                    }

                    TotalRetailValue += (SellingPrice * AvaQty);
                    TotalInvValue    += (AvgCost * AvaQty);
                }

                foreach (DataRow r in ItemsDatatable.Rows)
                {
                    AvgCost   = double.Parse(r["AvgUnitCost"].ToString());
                    AvaQty    = double.Parse(r["Qty"].ToString());
                    TotalQty += AvaQty;
                    if (AvaQty <= 0)
                    {
                        continue;
                    }
                    DataRow aRow = ToPrintTable.Rows.Add();
                    aRow["Name"]               = r["Description"];
                    aRow["Ava Qty"]            = Math.Round(AvaQty, 3);
                    aRow["Avg Cost"]           = Math.Round(AvgCost, 3);
                    aRow["Inventory Value"]    = Math.Round(AvgCost * AvaQty, 3);
                    SellingPrice               = double.Parse(r["SellPrice"].ToString());
                    aRow["Selling Price"]      = Math.Round(SellingPrice, 3);
                    aRow["Retail Value"]       = Math.Round(SellingPrice * AvaQty, 3);
                    aRow["% of Tot Inventory"] = Math.Round(((AvgCost * AvaQty) / TotalInvValue) * 100, 3).ToString() + " %";
                    aRow["% of Tot Retail"]    = Math.Round(((SellingPrice * AvaQty) / TotalRetailValue) * 100, 3).ToString() + " %";
                }

                DataRow FinalRow = ToPrintTable.Rows.Add();
                FinalRow["Name"]               = "<td style=\"text-decoration:underline;\">" + "T O T A L";
                FinalRow["Ava Qty"]            = "<td style=\"text-decoration:underline;\">" + Math.Round(TotalQty, 3);
                FinalRow["Avg Cost"]           = "<td style=\"text-decoration:underline;\">" + " ";
                FinalRow["Selling Price"]      = "<td style=\"text-decoration:underline;\">" + " ";
                FinalRow["Inventory Value"]    = "<td style=\"text-decoration:underline;\">" + Math.Round(TotalInvValue, 3);
                FinalRow["Retail Value"]       = "<td style=\"text-decoration:underline;\">" + Math.Round(TotalRetailValue, 3);
                FinalRow["% of Tot Inventory"] = "<td style=\"text-decoration:underline;\">" + "100%";
                FinalRow["% of Tot Retail"]    = "<td style=\"text-decoration:underline;\">" + "100%";

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

                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);

                aHeaderList.Add("<b><font size=4>" + Text.ReportsNames.InvvaluationSummaryRepNm + " </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);
            }
        }
Example #21
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);
        }
Example #22
0
        public static bool ItemStatusReport(int ItemID, string DateFrom, string DateTo, bool TableBorder = false, bool Preview = true, bool PrintToThermal = false, bool ExportToPdf = false, bool ExportToExcel = false, string ExportPath = "", bool colored = false)
        {
            if (!ItemsMgmt.IsItemExistByID(ItemID))
            {
                return(false);
            }
            string           EmptyNoborderRow = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.NOBORDER + ReportsHelper.MANUAL_TD_OPTION_END + ReportsHelper.MANUAL_TD_END;
            List <DataTable> aDTlist          = new List <DataTable>();
            DataTable        aTable1          = new DataTable();

            if (TableBorder)
            {
                aTable1.Columns.Add("[Border=true1]" + "Barcode");
            }
            else
            {
                aTable1.Columns.Add("Barcode");
            }
            aTable1.Columns.Add("Description");
            aTable1.Columns.Add("Type");
            aTable1.Columns.Add("Qty");

            DataRow aItemRow = ItemsMgmt.SelectItemRowByID(ItemID);
            bool    AddEmpty = false;
            double  NetTotal = 0.00;
            DataRow __PoorRow;

            double OnHandQty             = double.Parse(aItemRow["OnHandQty"].ToString());
            double TotalBeforeBills      = BillDetailedMgmt.SelectAllSoldQty(ItemID, DateFrom, DateTo, 0, true);
            double TotalBeforeAdjust     = AdjustInventoryDetailedMgmt.SelectAllAdjustQty(ItemID, DateFrom, DateTo, -1, true);
            double TotalBeforeDispose    = DisposalDetailedMgmt.SelectAllDisposedQty(ItemID, DateFrom, DateTo, 0, true);
            double TotalBeforePurchase   = PurchaseVoucherDetailedMgmt.SelectAllPurchaseQty(ItemID, DateFrom, DateTo, 0, true);
            double TotalBeforeCusRet     = ReturnItemsCustDetailedMGMT.SelectAllReturnedQty(ItemID, DateFrom, DateTo, 0, true);
            double TotalBeforeVenReturns = ReturnItemsVendorDetailedMgmt.SelectAllReturnedQty(ItemID, DateFrom, DateTo, 0, true);

            double BegginingQty = OnHandQty - TotalBeforeBills + TotalBeforeAdjust - TotalBeforeDispose + TotalBeforePurchase + TotalBeforeCusRet - TotalBeforeVenReturns;

            if (BegginingQty != 0)
            {
                NetTotal    += BegginingQty;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Beginning Qty";
                __PoorRow[3] = Math.Round(BegginingQty, 3);
                AddEmpty     = true;
            }

            double TotalBills         = BillDetailedMgmt.SelectAllSoldQty(ItemID, DateFrom, DateTo, -1);
            double TotalReversedBills = BillDetailedMgmt.SelectAllSoldQty(ItemID, DateFrom, DateTo, 1);

            if (TotalBills != 0)
            {
                NetTotal    -= TotalBills;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Sales";
                __PoorRow[3] = Math.Round(0.00 - TotalBills, 3);
                AddEmpty     = true;
            }
            if (TotalReversedBills != 0)
            {
                NetTotal    += TotalReversedBills;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Reversed Sales";
                __PoorRow[3] = Math.Round((TotalReversedBills), 3);
                AddEmpty     = true;
            }

            double TotalAdjust = AdjustInventoryDetailedMgmt.SelectAllAdjustQty(ItemID, DateFrom, DateTo, -1);

            if (TotalAdjust != 0)
            {
                NetTotal    += TotalAdjust;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Inventory Adjust";
                __PoorRow[3] = Math.Round(TotalAdjust, 3);
                AddEmpty     = true;
            }
            double TotalDisposed         = DisposalDetailedMgmt.SelectAllDisposedQty(ItemID, DateFrom, DateTo, -1);
            double TotalReversedDisposed = DisposalDetailedMgmt.SelectAllDisposedQty(ItemID, DateFrom, DateTo, 1);

            if (TotalDisposed != 0)
            {
                NetTotal    -= TotalDisposed;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Disposed";
                __PoorRow[3] = Math.Round(0.00 - TotalDisposed, 3);
                AddEmpty     = true;
            }
            if (TotalReversedDisposed != 0)
            {
                NetTotal    += TotalReversedDisposed;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Reversed Disposals";
                __PoorRow[3] = Math.Round((0.00 - TotalReversedDisposed), 3);
                AddEmpty     = true;
            }
            double TotalPurchase         = PurchaseVoucherDetailedMgmt.SelectAllPurchaseQty(ItemID, DateFrom, DateTo, -1);
            double TotalReversedPurchase = PurchaseVoucherDetailedMgmt.SelectAllPurchaseQty(ItemID, DateFrom, DateTo, 1);

            if (TotalPurchase != 0)
            {
                NetTotal    += TotalPurchase;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Purchase";
                __PoorRow[3] = Math.Round((TotalPurchase), 3);
                AddEmpty     = true;
            }
            if (TotalReversedPurchase != 0)
            {
                NetTotal    -= TotalReversedPurchase;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Reversed Purchase";
                __PoorRow[3] = Math.Round((0.00 - TotalReversedPurchase), 3);
                AddEmpty     = true;
            }
            double TotalCustomerReturns         = ReturnItemsCustDetailedMGMT.SelectAllReturnedQty(ItemID, DateFrom, DateTo, -1);
            double TotalReversedCustomerReturns = ReturnItemsCustDetailedMGMT.SelectAllReturnedQty(ItemID, DateFrom, DateTo, 1);

            if (TotalCustomerReturns != 0)
            {
                NetTotal    += TotalCustomerReturns;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Customer Returns";
                __PoorRow[3] = Math.Round((TotalCustomerReturns), 3);
                AddEmpty     = true;
            }
            if (TotalReversedCustomerReturns != 0)
            {
                NetTotal    -= TotalReversedCustomerReturns;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Reversed Customer Returns";
                __PoorRow[3] = Math.Round((0.00 - TotalReversedCustomerReturns), 3);
                AddEmpty     = true;
            }
            double TotalVendorReturns         = ReturnItemsVendorDetailedMgmt.SelectAllReturnedQty(ItemID, DateFrom, DateTo, -1);
            double TotalReversedVendorReturns = ReturnItemsVendorDetailedMgmt.SelectAllReturnedQty(ItemID, DateFrom, DateTo, 1);

            if (TotalVendorReturns != 0)
            {
                NetTotal    -= TotalVendorReturns;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Vendors Returns";
                __PoorRow[3] = Math.Round((0.00 - TotalVendorReturns), 3);
                AddEmpty     = true;
            }
            if (TotalReversedVendorReturns != 0)
            {
                NetTotal    += TotalReversedVendorReturns;
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = "Total Reversed Vendors Returns";
                __PoorRow[3] = Math.Round((TotalReversedVendorReturns), 3);
                AddEmpty     = true;
            }

            if (NetTotal != 0)
            {
                __PoorRow    = aTable1.Rows.Add();
                __PoorRow[0] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Barcode"].ToString();
                __PoorRow[1] = (AddEmpty) ? EmptyNoborderRow : aItemRow["Description"].ToString();
                __PoorRow[2] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.MANUAL_TD_OPTION_END + "TOTAL" + ReportsHelper.MANUAL_TD_END;
                __PoorRow[3] = ReportsHelper.MANUAL_TD_OPTION_START + ReportsHelper.UNDERLINE + ReportsHelper.MANUAL_TD_OPTION_END + Math.Round((NetTotal), 3) + ReportsHelper.MANUAL_TD_END;
                AddEmpty     = true;
            }
            aDTlist.Add(aTable1);

            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>" + Text.ReportsNames.ItemSymmaryStatusRepName + " </font>");
            aHeaderList.Add("<b><font size=4>" + Text.ReportsText.DateRepTxt + ": " + DateTime.Now.ToShortDateString() + " </font>");
            aHeaderList.Add("<b><font size=4>" + Text.ReportsText.FromRepTxt + ": " + DateFrom + " " + Text.ReportsText.ToRepTxt + ": " + DateTo + " </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);
            }
        }
Example #23
0
        private void AddItemBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validators.TxtBoxNotEmpty(BarcodeTxtBox.Text) || WithoutBarcodeChkBox.Checked)
                {
                    BarcodeTxtBox.BackColor = BarcodeTxtBoxBGColor;
                    double ParsingOutTester = 0;
                    if (Validators.TxtBoxNotEmpty(QtyTxtBox.Text) && double.TryParse(QtyTxtBox.Text, out ParsingOutTester))
                    {
                        QtyTxtBox.BackColor = QtyTxtBoxBGColor;
                        if (Validators.TxtBoxNotEmpty(RenderPointTxtBox.Text) && double.TryParse(RenderPointTxtBox.Text, out ParsingOutTester))
                        {
                            RenderPointTxtBox.BackColor = RenderTxtBoxBGColor;
                            if (Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                            {
                                DescriptionTxtBox.BackColor = DescriptionBGColor;
                                if (Validators.TxtBoxNotEmpty(SellPriceTxtBox.Text) && double.TryParse(SellPriceTxtBox.Text, out ParsingOutTester))
                                {
                                    SellPriceTxtBox.BackColor = SellPriceBGColor;
                                    if (Validators.TxtBoxNotEmpty(AvgCostTxtBox.Text) && double.TryParse(AvgCostTxtBox.Text, out ParsingOutTester))
                                    {
                                        AvgCostTxtBox.BackColor = AvgUnitCostBGColor;

                                        bool IsPriceLevelsEmpty = false;

                                        foreach (var tb in Pricing.Controls.OfType <TextBox>())
                                        {
                                            if (!Validators.TxtBoxNotEmpty(tb.Text) || !double.TryParse(tb.Text, out ParsingOutTester))
                                            {
                                                IsPriceLevelsEmpty = true;
                                                tb.BackColor       = SharedVariables.TxtBoxRequiredColor;
                                            }
                                            else
                                            {
                                                tb.BackColor = Color.White;
                                            }
                                        }
                                        if (IsPriceLevelsEmpty)
                                        {
                                            MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.PriceLevelsTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                            return;
                                        }
                                        else
                                        {
                                            Items aItem = new Items();
                                            if (TypeComboBox.SelectedValue == null || CategoryComboBox.SelectedValue == null || VendorComboBox.SelectedValue == null || TaxLevelComboBox.SelectedValue == null)
                                            {
                                                MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                return;
                                            }
                                            aItem.Item_Type      = (int)TypeComboBox.SelectedValue;
                                            aItem.Item_Category  = (int)CategoryComboBox.SelectedValue;
                                            aItem.Vendor         = (int)VendorComboBox.SelectedValue;
                                            aItem.Item_Tax_Level = (int)TaxLevelComboBox.SelectedValue;

                                            if (WithoutBarcodeChkBox.Checked)
                                            {
                                                aItem.IsWithoutBarcode = 1;
                                                int aWithoutBarcode_Barcode = ItemsMgmt.SelectWithoutBarcode_Barcode();;
                                                if (aWithoutBarcode_Barcode == 0)
                                                {
                                                    MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[AddItemBtn_Click:Cannot Select Without Barcode _ Barcode] \n" + MsgTxt.PleaseTryAgainLaterTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                    return;
                                                }
                                                while (ItemsMgmt.IsItemExist(aWithoutBarcode_Barcode.ToString()))
                                                {
                                                    aWithoutBarcode_Barcode++;
                                                }
                                                aItem.Item_Barcode = "NOBC" + aWithoutBarcode_Barcode.ToString();
                                            }
                                            else
                                            {
                                                if (aThereIsWeigth && WeightChkBox.Checked && BarcodeTxtBox.Text.Length >= BarcodeLength)
                                                {
                                                    aItem.IsWeight         = 1;
                                                    aItem.IsWithoutBarcode = 0;
                                                    aItem.Item_Barcode     = BarcodeTxtBox.Text.Substring(0, BarcodeLength);
                                                }
                                                else
                                                {
                                                    aItem.IsWeight         = 0;
                                                    aItem.IsWithoutBarcode = 0;
                                                    aItem.Item_Barcode     = BarcodeTxtBox.Text;
                                                }
                                            }
                                            if (!ItemsMgmt.IsItemExist(aItem.Item_Barcode))
                                            {
                                                aItem.Item_Description = DescriptionTxtBox.Text;
                                                aItem.Avalable_Qty     = double.Parse(QtyTxtBox.Text);
                                                aItem.Render_Point     = double.Parse(RenderPointTxtBox.Text);
                                                aItem.Entry_Date       = DateTime.Now.ToShortDateString();

                                                double aSellPrice = double.Parse(SellPriceTxtBox.Text);
                                                double aUnitCost  = double.Parse(AvgCostTxtBox.Text);
                                                double aTax       = double.Parse(ItemTaxLevelMgmt.SelectItemTaxByID(aItem.Item_Tax_Level));

                                                if (TaxEnclodedChkBox.Checked)
                                                {
                                                    aItem.Sell_Price    = Math.Round(aSellPrice / ((aTax / 100) + 1), 5);
                                                    aItem.Avg_Unit_Cost = Math.Round(aUnitCost / ((aTax / 100) + 1), 5);
                                                }
                                                else
                                                {
                                                    aItem.Sell_Price    = aSellPrice;
                                                    aItem.Avg_Unit_Cost = aUnitCost;
                                                }
                                                if (!ItemsMgmt.AddItem(aItem))
                                                {
                                                    MessageBox.Show(MsgTxt.UnexpectedError + "DataBase: ItemsMgmt.AddItem" + MsgTxt.DidnotAdded + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                    this.Close();
                                                }
                                                int ItemID = ItemsMgmt.SelectItemIDByBarcode(aItem.Item_Barcode);
                                                foreach (var tb in Pricing.Controls.OfType <TextBox>())
                                                {
                                                    double atbSellPrice = double.Parse(tb.Text);
                                                    if (TaxEnclodedChkBox.Checked)
                                                    {
                                                        atbSellPrice = Math.Round(atbSellPrice / ((aTax / 100) + 1), 5);
                                                    }
                                                    Nullable <int> PriceLevelID = PriceLevelsMgmt.SelectPriceLevelIDByName(tb.Name);
                                                    if (PriceLevelID != null)
                                                    {
                                                        Nullable <int> IsAddSpecialPriceOK = SpecialPricesMgmt.AddSpecialPrice(ItemID, (int)PriceLevelID, atbSellPrice);
                                                        if (IsAddSpecialPriceOK == null)
                                                        {
                                                            MessageBox.Show(MsgTxt.PriceLevelsTxt + " " + tb.Name + " " + MsgTxt.DidnotAdded + "\n", MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        MessageBox.Show(MsgTxt.UnexpectedError + "DataBase: " + MsgTxt.PriceLevelsTxt + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                                        this.Close();
                                                    }
                                                }

                                                MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                DialogResult ret;
                                                ret = MessageBox.Show(MsgTxt.AddAnotherItemTxt, MsgTxt.InformationCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                                if (ret == DialogResult.Yes)
                                                {
                                                    ReloadForm();
                                                }
                                                else
                                                {
                                                    this.Close();
                                                }
                                            }
                                            else
                                            {
                                                MessageBox.Show(MsgTxt.BarcodeTxt + " " + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                                BarcodeTxtBox.Text = "";
                                            }
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.UnitCostTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        AvgCostTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                        AvgCostTxtBox.Focus();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.SellingPriceTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    SellPriceTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                    SellPriceTxtBox.Focus();
                                }
                            }
                            else
                            {
                                MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.DescriptionTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                                DescriptionTxtBox.Focus();
                            }
                        }
                        else
                        {
                            MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.RenderPointTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            RenderPointTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                            RenderPointTxtBox.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.ValidQtyTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        QtyTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        QtyTxtBox.Focus();
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseSelectTxt + "\n1)" + MsgTxt.BarcodeTxt + "\n2)" + MsgTxt.IfNotBarChkWithoutBarcodeTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    BarcodeTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                    BarcodeTxtBox.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\nException: IN[AddItemBtn_Click] \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                throw;
            }
        }
Example #24
0
        //[BARCODE FUNCTIONS]
        /// <summary>
        /// ADD ITEM USING BARCODE
        /// this is one of the major function which is used to add item using its barcode to the
        /// TELDGVIEW with the following columns
        /// [Barcode] [Qty] [Description] [PricePerUnit] [Tax]  [PriceTotal] [AvalQty]
        /// And this function loocks a bool called IsAddingItem
        /// Function Version 1.00
        /// Last Edited By Sari Sultan On October,7,2013
        /// changed sell price to AvgUnitCost TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value = aItemTable.Rows[0]["AvgUnitCost"].ToString();
        /// </summary>
        /// <param name="aBarcode"></param>
        /// <param name="IsFromGun"></param>
        private void AddItemUsingBarcode(string aBarcode, bool IsFromGun = false)
        {
            try
            {
                double    TotwgtPrice = 0;
                bool      dowgt       = false;
                DataTable aItemTable  = null;

                if (aThereIsWeigth && IsFromGun)
                {
                    if (aBarcode.Length > BarcodeLength)
                    {
                        aBarcode = aBarcode.Substring(0, BarcodeLength);
                        if (ItemsMgmt.IsItemWgtExist(aBarcode))
                        {
                            aItemTable = ItemsMgmt.SelectItemByBarCode(aBarcode);
                            string tempcoststr = aBarcode.Substring(BarcodeLength, aBarcode.Length - BarcodeLength);
                            if (double.TryParse(tempcoststr, out TotwgtPrice))
                            {
                                dowgt = true;
                            }
                        }
                        else
                        {
                            aItemTable = ItemsMgmt.SelectItemByBarCode(aBarcode);
                        }
                    }
                    else
                    {
                        aItemTable = ItemsMgmt.SelectItemByBarCode(aBarcode);
                    }
                }
                else
                {
                    aItemTable = ItemsMgmt.SelectItemByBarCode(aBarcode);
                }

                if (aItemTable != null)
                {
                    if (aItemTable.Rows.Count == 1)
                    {
                        double TaxPer = double.Parse(ItemTaxLevelMgmt.SelectItemTaxByID(int.Parse(aItemTable.Rows[0]["TaxLevel"].ToString())));
                        foreach (DataGridViewRow r in TeldgView.Rows)
                        {
                            if (TeldgView.Rows[r.Index].Cells["Barcode"].Value.ToString() == aItemTable.Rows[0]["Barcode"].ToString())
                            {
                                TeldgView.ClearSelection();
                                if (dowgt)
                                {
                                    TeldgView.Rows[r.Index].Cells["Qty"].Value = Convert.ToDouble(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString()) + Math.Round(TotwgtPrice / DivisionScale / (double.Parse(aItemTable.Rows[0]["SellPrice"].ToString()) * (1 + TaxPer / 100)), 3);
                                }
                                else
                                {
                                    TeldgView.Rows[r.Index].Cells["Qty"].Value = Convert.ToDouble(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString()) + 1;
                                }
                                TeldgView.Rows[r.Index].Cells["PriceTotal"].Value = Math.Round(Convert.ToDouble(TeldgView.Rows[r.Index].Cells["Qty"].Value.ToString()) * Convert.ToDouble(TeldgView.Rows[r.Index].Cells["PricePerUnit"].Value.ToString()), 3);
                                TeldgView.Rows[r.Index].Selected = true;
                                return;
                            }
                        }
                        IsAddingItem = true;
                        TeldgView.ClearSelection();
                        int RowNum = TeldgView.Rows.Add();
                        TeldgView.Rows[RowNum].Cells["Barcode"].Value      = aItemTable.Rows[0]["Barcode"].ToString();
                        TeldgView.Rows[RowNum].Cells["Description"].Value  = aItemTable.Rows[0]["Description"].ToString();
                        TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value = aItemTable.Rows[0]["AvgUnitCost"].ToString();
                        if (dowgt)
                        {
                            TeldgView.Rows[RowNum].Cells["Qty"].Value = Math.Round((TotwgtPrice / DivisionScale) / (double.Parse(aItemTable.Rows[0]["SellPrice"].ToString()) * (1 + TaxPer / 100)), 3);
                        }
                        else
                        {
                            TeldgView.Rows[RowNum].Cells["Qty"].Value = 1;
                        }
                        TeldgView.Rows[RowNum].Cells["PriceTotal"].Value = Math.Round(double.Parse(TeldgView.Rows[RowNum].Cells["PricePerUnit"].Value.ToString()) * Convert.ToDouble(TeldgView.Rows[RowNum].Cells["Qty"].Value.ToString()), 3);
                        TeldgView.Rows[RowNum].Cells["Tax"].Value        = TaxPer;
                        TeldgView.Rows[RowNum].Cells["AvalQty"].Value    = aItemTable.Rows[0]["Qty"].ToString();
                        TeldgView.Rows[RowNum].Selected = true;
                    }
                    else
                    {
                        MessageBox.Show(MsgTxt.ItemNotFoundTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    IsAddingItem = false;
                }
            }
            catch (Exception ex)
            {
                IsAddingItem = false;
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddItemUsingBarcode] \n Exception: \n" + ex.ToString(), MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Example #25
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;
            }
        }
Example #26
0
 private void ReviseBillBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (aPurchaseDataRow["IsRevised"].ToString() == "0")
         {
             if (CashMethodComboBox.SelectedIndex == 1)//iscredit
             {
                 int     VendorID       = VendorsMgmt.SelectVendorIDByName(VendorsComboBox.Text);
                 DataRow aVendorAccount = VendorsAccountsMgmt.SelectVendorAccountRowByVendorID(VendorID);
                 double  OldAmount      = double.Parse(aVendorAccount["Amount"].ToString());
                 double  NewAmount      = OldAmount - double.Parse(TotalTxtBox.Text);
                 int     AccountID      = int.Parse(aVendorAccount["ID"].ToString());
                 VendorsAccountsMgmt.UpdateAccountAmountByAccountID(AccountID, NewAmount);
             }
             else
             {
                 int     AccountID   = int.Parse(aPurchaseDataRow["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(aPurchaseDataRow["PaymentMethodID"].ToString()));
             if (aMethodRow["IsCheck"].ToString() == "1")
             {
                 ChecksMgmt.MakeCheckRevised(int.Parse(aPurchaseDataRow["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 ItemCost           = PurchaseVoucherDetailedMgmt.SelectItemCostByNumber(ItemID, int.Parse(aPurchaseDataRow["VoucherNumber"].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 * CurrentAvaQty) + (ReturnQty * ItemCost)) / (ReturnQty + CurrentAvaQty);
                     ItemsMgmt.UpdateItemQtyandAvgUnitCostByID(ItemID, (ReturnQty + CurrentAvaQty), NewAvgUnitCost);
                     PurchaseVoucherDetailedMgmt.MakeItemAsRevised(int.Parse(aPurchaseDataRow["VoucherNumber"].ToString()), ItemID);
                 }
             }
             //Now we should mark the bill general as reversed
             if (!PurchaseVoucherGeneralMgmt.UpdateVoucherToRevised(TellerUserNameLbl.Text, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), int.Parse(aPurchaseDataRow["VoucherNumber"].ToString()), CostLoss))
             {
                 MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DB-ERROR-EditBill-ReviseBillBtn_Click] " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 this.Close();
             }
             else
             {
                 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 [EditVoucher-ReviseBillBtn_Click] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
         throw;
     }
 }
Example #27
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);
            }
        }
Example #28
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}"); }
            }
        }
Example #29
0
        private void Add1000Sale_Click(object sender, EventArgs e)
        {
            int      cnt        = 1;
            DateTime date       = DateTime.Now;
            var      randAmount = new Random();

            int userId = int.Parse(UsersMgmt.SelectAllUsers().Rows[0]["ID"].ToString());

            while (cnt++ < NumberOfBills)
            {
                try
                {
                    int numofDetailed = randAmount.Next(1, 20);
                    var aBillGeneral  = new BillGeneral();
                    aBillGeneral.Bill_General_AccountID       = 1;
                    aBillGeneral.Bill_General_CashIn          = 100;
                    aBillGeneral.Bill_General_Currency        = "JOD";
                    aBillGeneral.Bill_General_CurrencyID      = 1;
                    aBillGeneral.Bill_General_CustomerID      = 1;
                    aBillGeneral.Bill_General_Date            = date.Subtract(TimeSpan.FromDays(randAmount.Next(1, 2000))).ToShortDateString();
                    aBillGeneral.Bill_General_DiscountPerc    = 0;
                    aBillGeneral.Bill_General_IsCashCredit    = 0;
                    aBillGeneral.Bill_General_NetAmount       = 100;
                    aBillGeneral.Bill_General_Number          = BillGeneralMgmt.NextBillNumber();
                    aBillGeneral.Bill_General_PaymentMethodID = 1;
                    aBillGeneral.Bill_General_PriceLevel      = 1;
                    aBillGeneral.Bill_General_SalesDiscount   = 0;
                    aBillGeneral.Bill_General_SubTotal        = 100;
                    aBillGeneral.Bill_General_TellerID        = userId;
                    aBillGeneral.Bill_General_Time            =
                        DateTime.Now.ToShortTimeString();
                    aBillGeneral.Bill_General_TotalCost      = randAmount.Next(50, 99);
                    aBillGeneral.Bill_General_TotalDiscount  = 0;
                    aBillGeneral.Bill_General_TotalItems     = numofDetailed;
                    aBillGeneral.Bill_General_TotalPrice     = 100;
                    aBillGeneral.Bill_General_TotalTax       = 16;
                    aBillGeneral.CustomerAccountAmountOld    = 0;
                    aBillGeneral.Bill_General_Comments       = "Test Sale";
                    aBillGeneral.Bill_General_CreditCardInfo = "NotCredit";

                    Random aRandom = new Random();

                    if (BillGeneralMgmt.InsertBill(aBillGeneral))
                    {
                        while (numofDetailed > 0)
                        {
                            BillDetailed aBillDetailed = new BillDetailed();
                            string       aBarcode      = "Test Item " + aRandom.Next(1, (int)NumberOfItems);
                            DataTable    aItemRow      = ItemsMgmt.SelectItemByBarCode(aBarcode);
                            if (aItemRow.Rows.Count != 0)
                            {
                                aBillDetailed.Bill_Detailed_ItemDescription = aItemRow.Rows[0]["Description"].ToString();
                                aBillDetailed.Bill_Detailed_ItemID          = int.Parse(aItemRow.Rows[0]["ID"].ToString());
                                aBillDetailed.Bill_Detailed_Number          = aBillGeneral.Bill_General_Number;
                                aBillDetailed.Bill_Detailed_OldAvaQty       = double.Parse(aItemRow.Rows[0]["Qty"].ToString());
                                aBillDetailed.Bill_Detailed_OldAvgUnitCost  =
                                    double.Parse(aItemRow.Rows[0]["AvgUnitCost"].ToString());
                                aBillDetailed.Bill_Detailed_Qty       = numofDetailed;
                                aBillDetailed.Bill_Detailed_SellPrice = double.Parse(aItemRow.Rows[0]["SellPrice"].ToString());

                                aBillDetailed.Bill_Detailed_TotalPerUnit = aBillDetailed.Bill_Detailed_Qty *
                                                                           aBillDetailed.Bill_Detailed_SellPrice;

                                BillDetailedMgmt.InsertItem(aBillDetailed);
                            }
                            numofDetailed--;
                        }
                    }
                    if (cnt % 100 == 0)
                    {
                        label1.Text = $"Adding Bill {cnt}/{NumberOfBills} ... ({(cnt / NumberOfBills) * 100 })%";
                        Application.DoEvents();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"Error in {cnt} \n {ex}");
                }
            }
        }