Example #1
0
        private void GenerateItemsConfigs()
        {
            for (var i = 0; i < NumberOfConfigs; i++)
            {
                var atype = new ItemType
                {
                    Item_Type_Description = $"test {i}",
                    Item_Type_Name        = $"test {i}"
                };
                ItemTypeMgmt.AddItemType(atype);

                var aCategory = new ItemCategory
                {
                    Item_Category_Description = $"test {i}",
                    Item_Category_Name        = $"test {i}"
                };
                ItemCategoryMgmt.AddItemCategory(aCategory);

                var aVendors = new Vendors
                {
                    Vendor_Company    = $"test {i}",
                    Vendor_Email      = $"test {i}",
                    Vendor_Location   = $"test {i}",
                    Vendor_Name       = $"test {i}",
                    Vendor_Phone1     = "000",
                    Vendor_Phone2     = "222",
                    Vendor_Start_Date = "1/1/2009"
                };
                VendorsMgmt.AddVendor(aVendors);
            }
        }
Example #2
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 #3
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 #4
0
        private void AddTypeBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validators.TxtBoxNotEmpty(NameTxtBox.Text) && Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                {
                    Nullable <int> Check = ItemTypeMgmt.IsTypeUsedByName(NameTxtBox.Text);
                    if (Check == 10)
                    {
                        ItemType aItemType = new ItemType();
                        aItemType.Item_Type_Name        = NameTxtBox.Text;
                        aItemType.Item_Type_Description = DescriptionTxtBox.Text;
                        if (!ItemTypeMgmt.AddItemType(aItemType))
                        {
                            MessageBox.Show(MsgTxt.UnexpectedError + "\nCannot Add Item Type\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show(MsgTxt.AddedSuccessfully, MsgTxt.AddedSuccessfully, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                    }
                    else if (Check == 5)
                    {
                        MessageBox.Show(MsgTxt.ItemTypeTxt + "\n" + NameTxtBox.Text + "\n" + MsgTxt.AlreadyUsedTxt, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (Check == null)
                    {
                        MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [DataBase Error :Connection Problem In[AddTypeBtn_Click]  \n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (!Validators.TxtBoxNotEmpty(DescriptionTxtBox.Text))
                    {
                        DescriptionTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        DescriptionTxtBox.Focus();
                    }
                    else
                    {
                        DescriptionTxtBox.BackColor = DescBGColor;
                    }

                    if (!Validators.TxtBoxNotEmpty(NameTxtBox.Text))
                    {
                        NameTxtBox.BackColor = SharedVariables.TxtBoxRequiredColor;
                        NameTxtBox.Focus();
                    }
                    else
                    {
                        NameTxtBox.BackColor = NameBGColor;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [AddCategoryBtn_Click] -  \nException:\n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
Example #5
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 #6
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);
            }
        }