Exemple #1
0
        public int InventoryQuantityAvailableForPurchase(Product p, string variantId)
        {
            int result = 0;

            if (p.InventoryMode == ProductInventoryMode.AlwayInStock)
            {
                return(9999);
            }

            List <ProductInventory> inv = ProductInventories.FindByProductId(p.Bvin);

            if (variantId != string.Empty)
            {
                var vi = (from pi in inv
                          where pi.VariantId == variantId
                          select pi).SingleOrDefault();
                if (vi != null)
                {
                    result = vi.QuantityAvailableForSale;
                }
            }
            else
            {
                // no variants
                result = (from pi in inv
                          select pi).Sum(y => y.QuantityAvailableForSale);
            }

            return(result);
        }
Exemple #2
0
        protected void lstItem_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
        {
            HtmlInputCheckBox chkList     = (HtmlInputCheckBox)e.Item.FindControl("chkList");
            HtmlInputCheckBox chkMatrixID = (HtmlInputCheckBox)e.Item.FindControl("chkMatrixID");
            string            stParam     = "?task=" + Common.Encrypt("list", Session.SessionID) +
                                            "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID);

            switch (e.CommandName)
            {
            case "imgSaveOrderSlipPrinter":
            {
                TextBox txtActualQuantity = (TextBox)e.Item.FindControl("txtActualQuantity");
                try { decimal.Parse(txtActualQuantity.Text); }
                catch
                {
                    string stScript = "<Script>";
                    stScript += "window.alert('Please enter a VALID actual quantity.')";
                    stScript += "</Script>";
                    Response.Write(stScript);
                    break;
                }
                ProductInventories clsProductInventories = new ProductInventories();
                clsProductInventories.UpdateActualQuantity(int.Parse(cboBranch.SelectedItem.Value), long.Parse(chkList.Value), long.Parse(chkMatrixID.Value), decimal.Parse(txtActualQuantity.Text));
                clsProductInventories.CommitAndDispose();
            }
            break;
            }
        }
Exemple #3
0
        private void LoadList()
        {
            string SortField = "ProductCode";

            if (Request.QueryString["sortfield"] != null)
            {
                SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);
            }

            SortOption sortoption = SortOption.Ascending;

            if (Request.QueryString["sortoption"] != null)
            {
                sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);
            }

            Int64 intProductGroupID = Convert.ToInt64(cboProductGroup.SelectedItem.Value);

            ProductInventories clsProductInventories = new ProductInventories();

            System.Data.DataTable dt = clsProductInventories.ListAsDataTable(BranchID: int.Parse(cboBranch.SelectedItem.Value), ProductGroupID: intProductGroupID, clsProductListFilterType: ProductListFilterType.ShowActiveOnly, SortField: "ProductCode ASC, MatrixDescription ", SortOrder: SortOption.Desscending);

            clsProductInventories.CommitAndDispose();

            PageData.DataSource = dt.DefaultView;

            int iPageSize = Convert.ToInt16(Session["PageSize"]);

            PageData.AllowPaging = true;
            PageData.PageSize    = 5000;
            try
            {
                PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }
            catch
            {
                PageData.CurrentPageIndex = 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }

            cboCurrentPage.Items.Clear();
            for (int iRow = 0; iRow < PageData.PageCount; iRow++)
            {
                int iValue = iRow + 1;
                cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString()));
                if (PageData.CurrentPageIndex == iRow)
                {
                    cboCurrentPage.Items[iRow].Selected = true;
                }
                else
                {
                    cboCurrentPage.Items[iRow].Selected = false;
                }
            }
            lblDataCount.Text = " of " + " " + PageData.PageCount;
        }
Exemple #4
0
        public bool InventoryCreateWithStatusSave(ProductInventory inv)
        {
            bool result = ProductInventories.Create(inv);

            if (result)
            {
                UpdateProductVisibleStatusAndSave(inv.ProductBvin);
            }
            return(result);
        }
Exemple #5
0
        public bool InventoryUnreserveQuantity(string productBvin, string variantId, int quantity)
        {
            bool             result = false;
            ProductInventory inv    = ProductInventories.FindByProductIdAndVariantId(productBvin, variantId);

            if (inv != null)
            {
                inv.QuantityReserved -= quantity;
                ProductInventories.Update(inv);
                UpdateProductVisibleStatusAndSave(productBvin);
            }
            return(result);
        }
Exemple #6
0
        public bool InventorySetAvailableQuantity(string productId, string variantId, int quantity)
        {
            bool             result = false;
            ProductInventory inv    = ProductInventories.FindByProductIdAndVariantId(productId, variantId);

            if (inv != null)
            {
                inv.QuantityOnHand = quantity;
                result             = ProductInventories.Update(inv);
                UpdateProductVisibleStatusAndSave(inv.ProductBvin);
            }
            return(result);
        }
Exemple #7
0
        public bool InventoryIsProductVisible(Catalog.Product product)
        {
            if (product.Status == ProductStatus.Disabled)
            {
                return(false);
            }
            else
            {
                if (product.InventoryMode == ProductInventoryMode.AlwayInStock)
                {
                    return(true);
                }
                else
                {
                    List <Catalog.ProductInventory> inv = ProductInventories.FindByProductId(product.Bvin);

                    // no inventory info so assume it's available
                    if (inv == null)
                    {
                        return(true);
                    }
                    if (inv.Count < 1)
                    {
                        return(true);
                    }

                    bool foundStock = false;
                    foreach (ProductInventory piv in inv)
                    {
                        if (piv.InventoryEvaluateStatus(product) == ProductInventoryStatus.Available)
                        {
                            return(true);
                        }
                        else
                        {
                            if (product.InventoryMode != ProductInventoryMode.WhenOutOfStockHide)
                            {
                                return(true);
                            }
                        }
                    }

                    if (!foundStock)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemple #8
0
        protected void lstItem_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
        {
            HtmlInputCheckBox chkList     = (HtmlInputCheckBox)e.Item.FindControl("chkList");
            HtmlInputCheckBox chkMatrixID = (HtmlInputCheckBox)e.Item.FindControl("chkMatrixID");
            string            stParam     = "?task=" + Common.Encrypt("list", Session.SessionID) +
                                            "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID);


            switch (e.CommandName)
            {
            case "imgProductTag":
            {
                ImageButton imgProductTag = (ImageButton)e.Item.FindControl("imgProductTag");
                Products    clsProduct    = new Products();

                if (imgProductTag.ToolTip == "Tag this product as INACTIVE.")
                {
                    clsProduct.TagInactive(long.Parse(chkList.Value));
                    imgProductTag.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/prodtaginact.gif";
                    imgProductTag.ToolTip  = "Tag this product as ACTIVE.";
                }
                else
                {
                    clsProduct.TagActive(long.Parse(chkList.Value));
                    imgProductTag.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/prodtagact.gif";
                    imgProductTag.ToolTip  = "Tag this product as INACTIVE.";
                }
                clsProduct.CommitAndDispose();
            }
            break;

            case "imgSaveActualQuantity":
            {
                TextBox txtActualQuantity = (TextBox)e.Item.FindControl("txtActualQuantity");
                try { decimal.Parse(txtActualQuantity.Text); }
                catch
                {
                    string stScript = "<Script>";
                    stScript += "window.alert('Please enter a VALID actual quantity.')";
                    stScript += "</Script>";
                    Response.Write(stScript);
                    break;
                }
                ProductInventories clsProductInventories = new ProductInventories();
                clsProductInventories.UpdateActualQuantity(int.Parse(cboBranch.SelectedItem.Value), long.Parse(chkList.Value), long.Parse(chkMatrixID.Value), decimal.Parse(txtActualQuantity.Text));
                clsProductInventories.CommitAndDispose();
            }
            break;
            }
        }
Exemple #9
0
        protected void lstItem_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView dr = (DataRowView)e.Item.DataItem;

                HtmlInputCheckBox chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList");
                chkList.Value = dr[ProductColumnNames.ProductID].ToString();

                HyperLink lnkBarcode = (HyperLink)e.Item.FindControl("lnkBarcode");
                lnkBarcode.Text        = dr[ProductColumnNames.BarCode].ToString();
                lnkBarcode.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/Default.aspx?task=" + Common.Encrypt("det", Session.SessionID) + "&id=" + Common.Encrypt(dr[ProductColumnNames.ProductID].ToString(), Session.SessionID);

                HyperLink lnkProductCode = (HyperLink)e.Item.FindControl("lnkProductCode");
                lnkProductCode.Text = dr[ProductColumnNames.ProductCode].ToString();
                if (!string.IsNullOrEmpty(dr["MatrixDescription"].ToString()))
                {
                    lnkProductCode.Text += " - " + dr["MatrixDescription"].ToString();
                }
                lnkProductCode.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/Default.aspx?task=" + Common.Encrypt("det", Session.SessionID) + "&id=" + Common.Encrypt(dr[ProductColumnNames.ProductID].ToString(), Session.SessionID);

                Label lblGroup = (Label)e.Item.FindControl("lblGroup");
                lblGroup.Text = dr[ProductColumnNames.ProductGroupCode].ToString() + " / " + dr[ProductColumnNames.ProductSubGroupCode].ToString();

                Label lblQuantity = (Label)e.Item.FindControl("lblQuantity");
                // lblQuantity.Text = Convert.ToDecimal(dr[ProductColumnNames.MainQuantity].ToString()).ToString("#,##0.#0") + " " + dr[ProductColumnNames.BaseUnitCode];
                lblQuantity.Text = dr[ProductColumnNames.ConvertedQuantity].ToString();

                Label lblMinThreshold = (Label)e.Item.FindControl("lblMinThreshold");
                lblMinThreshold.Text = Convert.ToDecimal(dr[ProductColumnNames.MinThreshold].ToString()).ToString("#,##0.#0");

                Label lblMaxThreshold = (Label)e.Item.FindControl("lblMaxThreshold");
                lblMaxThreshold.Text = Convert.ToDecimal(dr[ProductColumnNames.MaxThreshold].ToString()).ToString("#,##0.#0");

                if (cboBranch.SelectedItem.Value == Constants.ZERO_STRING &&
                    (cboContact.SelectedItem.Value != Constants.ZERO_STRING || cboProductGroup.SelectedItem.Value != Constants.ZERO_STRING || cboSubGroup.SelectedItem.Value != Constants.ZERO_STRING))
                {
                    ProductInventories    clsProduct = new ProductInventories();
                    System.Data.DataTable dt         = clsProduct.ListAsDataTable(ProductID: long.Parse(dr[ProductColumnNames.ProductID].ToString()), MatrixID: long.Parse(dr["MatrixID"].ToString()), isSummary: 0);
                    clsProduct.CommitAndDispose();

                    DataList lstBranchInventory = (DataList)e.Item.FindControl("lstBranchInventory");
                    lstBranchInventory.Visible    = true;
                    lstBranchInventory.DataSource = dt.DefaultView;
                    lstBranchInventory.DataBind();
                }
            }
        }
Exemple #10
0
        public void CleanUpInventory(Product p)
        {
            if (p == null)
            {
                return;
            }
            List <ProductInventory> allInventory = ProductInventories.FindByProductId(p.Bvin);

            if (allInventory == null)
            {
                return;
            }
            if (allInventory.Count < 1)
            {
                return;
            }

            if (p.HasVariants())
            {
                foreach (ProductInventory inv in allInventory)
                {
                    if (inv.VariantId.Trim() == string.Empty)
                    {
                        // Remove non-variant inventory levels
                        ProductInventories.Delete(inv.Bvin);
                    }

                    if (p.Variants.Where(y => y.Bvin == inv.VariantId).Count() <= 0)
                    {
                        // Remove variant inventory levels that don't apply anymore
                        ProductInventories.Delete(inv.Bvin);
                    }
                }
            }
            else
            {
                // Remove all variant inventory levels
                foreach (ProductInventory inv in allInventory)
                {
                    if (inv.VariantId.Trim() != string.Empty)
                    {
                        ProductInventories.Delete(inv.Bvin);
                    }
                }
            }
        }
Exemple #11
0
        private string CloseInventory()
        {
            string strRetValue = "";

            try
            {
                DateTime DeliveryDate = Convert.ToDateTime(txtClosingDate.Text);

                ERPConfig        clsERPConfig        = new ERPConfig();
                ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

                if (clsERPConfigDetails.PostingDateFrom <= DeliveryDate && clsERPConfigDetails.PostingDateTo >= DeliveryDate)
                {
                    string strReferenceNo = Constants.CLOSE_INVENTORY_CODE + CompanyDetails.BECompanyCode + DateTime.Now.Year.ToString() + clsERPConfig.get_LastClosingNo();

                    AccessUserDetails clsAccessUserDetails = (AccessUserDetails)Session["AccessUserDetails"];

                    ProductInventories clsProductInventories = new ProductInventories(clsERPConfig.Connection, clsERPConfig.Transaction);
                    clsProductInventories.CloseInventoryBySupplier(int.Parse(cboBranch.SelectedItem.Value), clsAccessUserDetails.UID, DateTime.Parse(txtClosingDate.Text), strReferenceNo, long.Parse(cboContact.SelectedItem.Value), cboContact.SelectedItem.Text);

                    Products clsProducts = new Products(clsERPConfig.Connection, clsERPConfig.Transaction);
                    clsProducts.LockUnlockForSellingBySupplier(int.Parse(cboBranch.SelectedItem.Value), long.Parse(cboContact.SelectedItem.Value), false);

                    clsERPConfig.CommitAndDispose();
                    strRetValue = strReferenceNo;
                }
                else
                {
                    clsERPConfig.CommitAndDispose();
                    string stScript = "<Script>";
                    stScript += "window.alert('Sorry you cannot close using the closing date: " + txtClosingDate.Text + ". Please enter an allowable posting date.')";
                    stScript += "</Script>";
                    Response.Write(stScript);
                }
            }
            catch (Exception ex)
            {
                string stScript = "<Script>";
                stScript += "window.alert('An error has occured while closing the inventory. Details:' " + ex.Message + ")";
                stScript += "</Script>";
                Response.Write(stScript);
            }
            return(strRetValue);
        }
Exemple #12
0
        private void SaveThresholds()
        {
            HtmlInputCheckBox chkMatrixID              = null;
            HtmlInputCheckBox chkList                  = null;
            TextBox           txtBranchMinThreshold    = null;
            TextBox           txtBranchMaxThreshold    = null;
            TextBox           txtRIDBranch             = null;
            TextBox           txtRIDBranchMinThreshold = null;
            TextBox           txtRIDBranchMaxThreshold = null;
            int intBranchID = int.Parse(cboBranch.SelectedItem.Value);

            ProductInventories clsProductInventories = new ProductInventories();

            foreach (DataListItem item in lstItem.Items)
            {
                txtBranchMinThreshold    = (TextBox)item.FindControl("txtBranchMinThreshold");
                txtBranchMaxThreshold    = (TextBox)item.FindControl("txtBranchMaxThreshold");
                txtRIDBranch             = (TextBox)item.FindControl("txtRIDBranch");
                txtRIDBranchMinThreshold = (TextBox)item.FindControl("txtRIDBranchMinThreshold");
                txtRIDBranchMaxThreshold = (TextBox)item.FindControl("txtRIDBranchMaxThreshold");

                chkList     = (HtmlInputCheckBox)item.FindControl("chkList");
                chkMatrixID = (HtmlInputCheckBox)item.FindControl("chkMatrixID");
                try
                {
                    clsProductInventories.UpdateThresholds(Int32.Parse(cboBranch.SelectedItem.Value), Int64.Parse(chkList.Value), Int64.Parse(chkMatrixID.Value),
                                                           decimal.Parse(txtBranchMinThreshold.Text), decimal.Parse(txtBranchMaxThreshold.Text), Int32.Parse(txtRIDBranch.Text),
                                                           decimal.Parse(txtRIDBranchMinThreshold.Text), decimal.Parse(txtRIDBranchMaxThreshold.Text));

                    //decimal decActualQuantity = decimal.Parse(txtActualQuantity.Text);
                    //clsProductInventories.UpdateActualQuantity(intBranchID, long.Parse(chkList.Value), long.Parse(chkMatrixID.Value), decActualQuantity);
                    //txtActualQuantity.Text = Server.HtmlEncode(decActualQuantity.ToString("#,##0.#0"));
                }
                catch { }
            }
            clsProductInventories.CommitAndDispose();
            LoadList();
        }
Exemple #13
0
        private void SetDataSource(ReportDocument Report)
        {
            ReportDataset rptds = new ReportDataset();

            string ContactCode = string.Empty;

            if (cboContact.SelectedItem.Value != Constants.ZERO_STRING)
            {
                ContactCode = cboContact.SelectedItem.Text;
            }

            string ProductGroupName = string.Empty;

            if (cboGroup.SelectedItem.Value != Constants.ZERO_STRING)
            {
                ProductGroupName = cboGroup.SelectedItem.Text;
            }

            string ProductSubGroupName = string.Empty;

            if (cboSubGroup.SelectedItem.Value != Constants.ZERO_STRING)
            {
                ProductSubGroupName = cboSubGroup.SelectedItem.Text;
            }

            System.Data.DataTable dt = null;
            if (lblType.Text == "invcount")
            {
                Int64 lngSupplierID = Convert.ToInt64(cboContact.SelectedItem.Value);

                Int64 lngProductgroupID = Convert.ToInt64(cboGroup.SelectedItem.Value);

                Int64 lngProductSubGroupID = Convert.ToInt64(cboSubGroup.SelectedItem.Value);

                ProductInventories clsProductInventories = new ProductInventories();

                dt = clsProductInventories.ListAsDataTable(BranchID: int.Parse(lblBranchID.Text), SupplierID: lngSupplierID, ProductGroupID: lngProductgroupID, ProductSubGroupID: lngProductSubGroupID, clsProductListFilterType: ProductListFilterType.ShowActiveOnly, SortField: "ProductCode ASC, MatrixDescription ASC, BarCode1", SortOrder: SortOption.Desscending);

                //Contacts clsContacts = new Contacts(clsProductInventories.Connection, clsProductInventories.Transaction);
                //ContactDetails clsContactDetails = clsContacts.Details(lngSupplierID);

                clsProductInventories.CommitAndDispose();

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    DataRow drInventory = rptds.ProductInventory.NewRow();

                    foreach (DataColumn dc in rptds.ProductInventory.Columns)
                    {
                        drInventory[dc] = dr[dc.ColumnName];
                    }

                    rptds.ProductInventory.Rows.Add(drInventory);
                }
            }
            else
            {
                Data.Inventory clsInventory = new Data.Inventory();
                dt = clsInventory.DataList(cboInventoryNo.SelectedItem.Text, chkIncludeShortOverProducts.Checked, long.Parse(cboContact.SelectedItem.Value), long.Parse(cboGroup.SelectedItem.Value), SortField: "InventoryID", SortOrder: SortOption.Ascending);
                clsInventory.CommitAndDispose();

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    DataRow drInventory = rptds.Inventory.NewRow();

                    foreach (DataColumn dc in rptds.Inventory.Columns)
                    {
                        drInventory[dc] = dr[dc.ColumnName];
                    }

                    rptds.Inventory.Rows.Add(drInventory);
                }
            }


            Report.SetDataSource(rptds);

            SetParameters(Report);
        }
Exemple #14
0
        public int InventoryReserveQuantity(string productBvin, string variantId, int quantity, bool ReserveZeroWhenQuantityTooLow)
        {
            Catalog.ProductInventory inv = ProductInventories.FindByProductIdAndVariantId(productBvin, variantId);

            // If no inventory, assume available
            if (inv == null)
            {
                return(quantity);
            }

            Catalog.Product prod = Products.Find(productBvin);
            if (prod != null)
            {
                if (prod.InventoryMode == ProductInventoryMode.AlwayInStock)
                {
                    return(quantity);
                }

                if (inv != null && inv.Bvin != string.Empty)
                {
                    switch (prod.InventoryMode)
                    {
                    case ProductInventoryMode.AlwayInStock:
                        inv.QuantityReserved += quantity;
                        ProductInventories.Update(inv);
                        return(quantity);

                    case ProductInventoryMode.WhenOutOfStockAllowBackorders:
                        inv.QuantityReserved += quantity;
                        ProductInventories.Update(inv);
                        return(quantity);

                    case ProductInventoryMode.WhenOutOfStockShow:
                        if (inv.QuantityAvailableForSale < quantity)
                        {
                            if (ReserveZeroWhenQuantityTooLow)
                            {
                                return(0);
                            }
                            else
                            {
                                inv.QuantityReserved += inv.QuantityAvailableForSale;
                                ProductInventories.Update(inv);
                                return(inv.QuantityAvailableForSale);
                            }
                        }
                        else
                        {
                            inv.QuantityReserved += quantity;
                            ProductInventories.Update(inv);
                            return(quantity);
                        }

                    case ProductInventoryMode.WhenOutOfStockHide:
                        if (inv.QuantityAvailableForSale < quantity)
                        {
                            if (ReserveZeroWhenQuantityTooLow)
                            {
                                return(0);
                            }
                            else
                            {
                                inv.QuantityReserved += inv.QuantityAvailableForSale;
                                ProductInventories.Update(inv);
                                return(inv.QuantityAvailableForSale);
                            }
                        }
                        else
                        {
                            inv.QuantityReserved += quantity;
                            ProductInventories.Update(inv);
                            return(quantity);
                        }
                    }
                    return(0);
                }
                else
                {
                    if (prod != null)
                    {
                        if (prod.InventoryMode == ProductInventoryMode.AlwayInStock)
                        {
                            return(0);
                        }
                        else
                        {
                            return(quantity);
                        }
                    }
                    else
                    {
                        return(0);
                    }
                }
            }

            return(0);
        }
Exemple #15
0
        private void SetDataSource(ReportDocument Report)
        {
            ReportDataset rptds = new ReportDataset();

            //long lngProductGroupName = long.Parse(cboProductGroup.SelectedItem.Value);
            //long lngSubGroupName = long.Parse(cboSubGroup.SelectedItem.Value);

            string ProductGroupName = string.Empty;

            if (cboProductGroup.SelectedItem.Value != Constants.ZERO_STRING)
            {
                ProductGroupName = cboProductGroup.SelectedItem.Value;
            }
            string SubGroupName = string.Empty;

            if (cboSubGroup.SelectedItem.Value != Constants.ZERO_STRING)
            {
                SubGroupName = cboSubGroup.SelectedItem.Value;
            }

            string ReportType = cboReportType.SelectedItem.Text;

            ProductColumns clsProductColumns = new ProductColumns();

            #region clsProductColumns
            clsProductColumns.ProductCode         = true;
            clsProductColumns.BarCode             = true;
            clsProductColumns.BarCode2            = true;
            clsProductColumns.BarCode3            = true;
            clsProductColumns.ProductDesc         = true;
            clsProductColumns.ProductSubGroupName = true;
            clsProductColumns.BaseUnitName        = true;
            clsProductColumns.UnitName            = true;
            clsProductColumns.ProductGroupName    = true;
            clsProductColumns.DateCreated         = true;
            clsProductColumns.Price           = true;
            clsProductColumns.Quantity        = true;
            clsProductColumns.MinThreshold    = true;
            clsProductColumns.MaxThreshold    = true;
            clsProductColumns.PurchasePrice   = true;
            clsProductColumns.SupplierName    = true;
            clsProductColumns.QuantityIN      = true;
            clsProductColumns.QuantityOUT     = true;
            clsProductColumns.RIDMinThreshold = true;
            clsProductColumns.RIDMaxThreshold = true;
            clsProductColumns.RID             = true;
            //clsProductColumns.BranchActualQuantity = true;
            //clsProductColumns.BranchQuantity = true;
            //clsProductColumns.BranchQuantityIN = true;
            //clsProductColumns.BranchQuantityOUT = true;
            #endregion

            ProductDetails clsSearchKey = new ProductDetails();
            #region Search Key
            clsSearchKey.BranchID          = Convert.ToInt32(cboBranch.SelectedItem.Value);
            clsSearchKey.SupplierID        = Convert.ToInt32(cboContact.SelectedItem.Value);
            clsSearchKey.ProductGroupID    = Convert.ToInt64(cboProductGroup.SelectedItem.Value);
            clsSearchKey.ProductSubGroupID = Convert.ToInt64(cboSubGroup.SelectedItem.Value);
            clsSearchKey.ProductCode       = txtProductCode.Text;
            #endregion

            Products clsProduct = new Products();
            clsProduct.GetConnection();
            ProductInventories clsProductInventories = new ProductInventories(clsProduct.Connection, clsProduct.Transaction);


            DataTable dt;
            string    ProductIDs = null;

            switch (cboReportType.SelectedValue)
            {
            case ReportTypes.ProductList:
                #region Products List
                dt = clsProductInventories.ListAsDataTable(Int32.Parse(cboBranch.SelectedItem.Value), SupplierID: long.Parse(cboContact.SelectedItem.Value), ProductGroupID: long.Parse(cboProductGroup.SelectedItem.Value), ProductSubGroupID: long.Parse(cboSubGroup.SelectedItem.Value), ProductCode: txtProductCode.Text);
                clsProduct.CommitAndDispose();

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    DataRow drNew = rptds.Products.NewRow();

                    foreach (DataColumn dc in rptds.Products.Columns)
                    {
                        drNew[dc] = dr[dc.ColumnName];
                    }

                    rptds.Products.Rows.Add(drNew);
                }
                break;
                #endregion

            case ReportTypes.ProductPriceList:
                #region Products Price List
                dt = clsProductInventories.ListAsDataTable(int.Parse(cboBranch.SelectedItem.Value), SupplierID: long.Parse(cboContact.SelectedItem.Value), ProductGroupID: long.Parse(cboProductGroup.SelectedItem.Value), ProductSubGroupID: long.Parse(cboSubGroup.SelectedItem.Value), ProductCode: txtProductCode.Text);
                clsProduct.CommitAndDispose();
                foreach (DataRow dr in dt.Rows)
                {
                    DataRow drNew = rptds.Products.NewRow();

                    foreach (DataColumn dc in rptds.Products.Columns)
                    {
                        drNew[dc] = dr[dc.ColumnName];
                    }

                    rptds.Products.Rows.Add(drNew);
                    ProductIDs += dr["ProductID"].ToString() + ",";
                }
                break;
                #endregion

            case ReportTypes.ProductListWithInvalidMatrix:
                #region Products List With Invalid Unit Matrix
                dt = clsProductInventories.ListAsDataTable(int.Parse(cboBranch.SelectedItem.Value), SupplierID: long.Parse(cboContact.SelectedItem.Value), ProductGroupID: long.Parse(cboProductGroup.SelectedItem.Value), ProductSubGroupID: long.Parse(cboSubGroup.SelectedItem.Value), ProductCode: txtProductCode.Text, ShowOnlyWithInvalidUnitMatrix: true);
                clsProduct.CommitAndDispose();

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    DataRow drNew = rptds.Products.NewRow();

                    foreach (DataColumn dc in rptds.Products.Columns)
                    {
                        drNew[dc] = dr[dc.ColumnName];
                    }

                    rptds.Products.Rows.Add(drNew);
                }
                break;

                #endregion
            case ReportTypes.WeightedProductsForWeighingScale:
            case ReportTypes.CountedProductsForWeighingScale:
                #region Weighted and Counted Products For Weighing Scale
                dt = clsProductInventories.ListAsDataTable(int.Parse(cboBranch.SelectedItem.Value), SupplierID: long.Parse(cboContact.SelectedItem.Value), ProductGroupID: long.Parse(cboProductGroup.SelectedItem.Value), ProductSubGroupID: long.Parse(cboSubGroup.SelectedItem.Value), ProductCode: txtProductCode.Text);
                clsProduct.CommitAndDispose();
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr[ProductColumnNames.BarCode].ToString() != null && dr[ProductColumnNames.BarCode].ToString() != string.Empty)
                    {
                        DataRow drNew = rptds.Products.NewRow();

                        foreach (DataColumn dc in rptds.Products.Columns)
                        {
                            drNew[dc] = dr[dc.ColumnName];
                        }

                        rptds.Products.Rows.Add(drNew);
                        ProductIDs += dr["ProductID"].ToString() + ",";
                    }
                }
                break;
                #endregion

            case ReportTypes.ProductsInDemoReport:
                #region Products In Demo
                DateTime StartTransactionDate = DateTime.TryParse(txtStartDate.Text + " " + txtStartTime.Text, out StartTransactionDate) ? StartTransactionDate : DateTime.MinValue;
                DateTime EndTransactionDate   = DateTime.TryParse(txtEndDate.Text + " " + txtEndTime.Text, out EndTransactionDate) ? EndTransactionDate : DateTime.MinValue;

                SalesTransactionItems clsSalesTransactionItemsDemo = new SalesTransactionItems();
                System.Data.DataTable dtDemo = clsSalesTransactionItemsDemo.ProductsInDemoReport(Int32.Parse(cboBranch.SelectedItem.Value), Int64.Parse(cboContact.SelectedItem.Value), cboProductGroup.SelectedItem.Text, cboSubGroup.SelectedItem.Text, txtProductCode.Text, "", StartTransactionDate, EndTransactionDate);
                clsSalesTransactionItemsDemo.CommitAndDispose();
                foreach (DataRow dr in dtDemo.Rows)
                {
                    DataRow drNew = rptds.ProductsInDemo.NewRow();

                    foreach (DataColumn dc in rptds.ProductsInDemo.Columns)
                    {
                        drNew[dc] = dr[dc.ColumnName];
                    }

                    rptds.ProductsInDemo.Rows.Add(drNew);
                }
                break;

                #endregion
            default:
                return;
            }

            Report.SetDataSource(rptds);
            SetParameters(Report);
        }
Exemple #16
0
        private void LoadList()
        {
            string SortField = "ProductCode";

            if (Request.QueryString["sortfield"] != null)
            {
                SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);
            }

            SortOption sortoption = SortOption.Ascending;

            if (Request.QueryString["sortoption"] != null)
            {
                sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);
            }

            Int64 lngSupplierID = Convert.ToInt64(cboContact.SelectedItem.Value);

            ProductInventories clsProductInventories = new ProductInventories();

            System.Data.DataTable dt = clsProductInventories.ListAsDataTable(BranchID: int.Parse(cboBranch.SelectedItem.Value), SupplierID: lngSupplierID, clsProductListFilterType: ProductListFilterType.ShowActiveOnly, SortField: "ProductCode ASC, MatrixDescription ASC, BarCode1", SortOrder: SortOption.Desscending);

            Contacts       clsContacts       = new Contacts(clsProductInventories.Connection, clsProductInventories.Transaction);
            ContactDetails clsContactDetails = clsContacts.Details(lngSupplierID);

            clsProductInventories.CommitAndDispose();

            PageData.DataSource = dt.DefaultView;

            if (!clsContactDetails.isLock)
            {
                cmdLockUnlockProduct.Text    = "Lock Supplier [<label class='ms-error'>Note:</label>Products under this supplier are <u>CURRENTLY ALLOWED</u> for Selling]";
                cmdLockUnlockProduct.ToolTip = "unlock";
            }
            else
            {
                cmdLockUnlockProduct.Text    = "UnLock Supplier [<label class='ms-error'>Note:</label>Products under this supplier are <u>CURRENTLY NOT ALLOWED</u> for Selling]";
                cmdLockUnlockProduct.ToolTip = "lock";
            }

            int iPageSize = Convert.ToInt16(Session["PageSize"]);

            PageData.AllowPaging = true;
            PageData.PageSize    = 5000;
            try
            {
                PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }
            catch
            {
                PageData.CurrentPageIndex = 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }

            cboCurrentPage.Items.Clear();
            for (int iRow = 0; iRow < PageData.PageCount; iRow++)
            {
                int iValue = iRow + 1;
                cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString()));
                if (PageData.CurrentPageIndex == iRow)
                {
                    cboCurrentPage.Items[iRow].Selected = true;
                }
                else
                {
                    cboCurrentPage.Items[iRow].Selected = false;
                }
            }
            lblDataCount.Text = " of " + " " + PageData.PageCount;
        }
Exemple #17
0
        private void SetDataSource(ReportDocument Report)
        {
            string strReportType = cboReportType.SelectedValue;

            Int32 ForReorder = 0;
            Int32 OverStock  = 0;

            if (strReportType == ReportTypes.ItemsForReOrder)
            {
                ForReorder = 1;
            }
            else if (strReportType == ReportTypes.OverStockItems)
            {
                OverStock = 1;
            }

            ReportDataset rptds = new ReportDataset();

            #region Search Key
            Int32  intBranchID          = Convert.ToInt32(cboBranch.SelectedItem.Value);
            Int64  lngSupplierID        = Convert.ToInt32(cboContact.SelectedItem.Value);
            Int64  lngProductGroupID    = Convert.ToInt64(cboProductGroup.SelectedItem.Value);
            Int64  lngProductSubGroupID = Convert.ToInt64(cboSubGroup.SelectedItem.Value);
            string stProductCode        = txtProductCode.Text;
            #endregion

            string ExpirationDate = Constants.C_DATE_MIN_VALUE_STRING;
            if (strReportType == ReportTypes.ExpiredInventory)
            {
                ExpirationDate = txtExpiryDate.Text;
            }

            int isSummary = intBranchID == 0 ? 1 : 0;
            ProductInventories    clsProductInventories;
            System.Data.DataTable dt;

            switch (strReportType)
            {
            case ReportTypes.SummarizedInventoryByBranch:
                clsProductInventories = new ProductInventories();
                dt = clsProductInventories.SummarizedInventory(SummarizedInventoryTypes.byBranch, intBranchID, lngSupplierID, lngProductGroupID, true);
                clsProductInventories.CommitAndDispose();

                foreach (DataRow dr in dt.Rows)
                {
                    DataRow drNew = rptds.SummarizedInventory.NewRow();

                    foreach (DataColumn dc in rptds.SummarizedInventory.Columns)
                    {
                        drNew[dc] = dr[dc.ColumnName];
                    }
                    rptds.SummarizedInventory.Rows.Add(drNew);
                }

                break;

            case ReportTypes.SummarizedInventoryBySupplier:
                clsProductInventories = new ProductInventories();
                dt = clsProductInventories.SummarizedInventory(SummarizedInventoryTypes.bySupplier, intBranchID, lngSupplierID, lngProductGroupID, true);
                clsProductInventories.CommitAndDispose();

                foreach (DataRow dr in dt.Rows)
                {
                    DataRow drNew = rptds.SummarizedInventory.NewRow();

                    foreach (DataColumn dc in rptds.SummarizedInventory.Columns)
                    {
                        drNew[dc] = dr[dc.ColumnName];
                    }
                    rptds.SummarizedInventory.Rows.Add(drNew);
                }

                break;

            case ReportTypes.SummarizedInventoryByGroup:
                clsProductInventories = new ProductInventories();
                dt = clsProductInventories.SummarizedInventory(SummarizedInventoryTypes.byGroup, intBranchID, lngSupplierID, lngProductGroupID, true);
                clsProductInventories.CommitAndDispose();

                foreach (DataRow dr in dt.Rows)
                {
                    DataRow drNew = rptds.SummarizedInventory.NewRow();

                    foreach (DataColumn dc in rptds.SummarizedInventory.Columns)
                    {
                        drNew[dc] = dr[dc.ColumnName];
                    }
                    rptds.SummarizedInventory.Rows.Add(drNew);
                }

                break;

            default:
                clsProductInventories = new ProductInventories();

                if (cboMonth.SelectedItem.Value == DateTime.Now.Month.ToString("0#") && cboYear.SelectedItem.Value == DateTime.Now.Year.ToString())
                {
                    dt = clsProductInventories.ListAsDataTable(BranchID: intBranchID, ProductCode: stProductCode, ProductGroupID: lngProductGroupID, ProductSubGroupID: lngProductSubGroupID, SupplierID: lngSupplierID, isSummary: isSummary, ExpirationDate: ExpirationDate, ForReorder: ForReorder, OverStock: OverStock);
                }
                else
                {
                    dt = clsProductInventories.ListAsDataTable(Month: int.Parse(cboMonth.SelectedItem.Value), Year: int.Parse(cboYear.SelectedItem.Value.ToString()), BranchID: intBranchID, ProductCode: stProductCode, ProductGroupID: lngProductGroupID, ProductSubGroupID: lngProductSubGroupID, SupplierID: lngSupplierID, isSummary: isSummary, ExpirationDate: ExpirationDate, ForReorder: ForReorder, OverStock: OverStock);
                }
                clsProductInventories.CommitAndDispose();

                foreach (DataRow dr in dt.Rows)
                {
                    //if (dr[ProductColumnNames.BarCode].ToString() != null && dr[ProductColumnNames.BarCode].ToString() != string.Empty)
                    //{
                    DataRow drNew = rptds.Products.NewRow();

                    foreach (DataColumn dc in rptds.Products.Columns)
                    {
                        drNew[dc] = dr[dc.ColumnName];
                    }
                    rptds.Products.Rows.Add(drNew);
                    //}
                }
                break;
            }


            Report.SetDataSource(rptds);

            SetParameters(Report);
        }
Exemple #18
0
        protected void cboProductCode_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (cboProductCode.SelectedItem.Text == "No product" || cboProductCode.SelectedItem.Text == "No Product; Enter product to search.")
            {
                lblVariationMatrix.Visible     = false;
                lnkVariationMatrixAdd.Visible  = false;
                lstVariationMatrix.Visible     = false;
                lblUnitName.Visible            = false;
                txtQuantityBefore.Visible      = false;
                txtDifference.Visible          = false;
                txtQuantityNow.Visible         = false;
                txtMinThreshold.Visible        = false;
                txtMaxThreshold.Visible        = false;
                imgProductHistory.Visible      = false;
                imgProductPriceHistory.Visible = false;
                imgChangePrice.Visible         = false;
                imgEditNow.Visible             = false;
            }
            else
            {
                lblVariationMatrix.Visible        = true;
                lnkVariationMatrixAdd.Visible     = true;
                lnkVariationMatrixAdd.ToolTip     = "Add new variation matrix for " + cboProductCode.SelectedItem.Text;
                lnkVariationMatrixAdd.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_VariationsMatrix/Default.aspx?task=" + Common.Encrypt("add", Session.SessionID) + "&prodid=" + Common.Encrypt(cboProductCode.SelectedValue, Session.SessionID);
                lblUnitName.Visible            = true;
                txtQuantityBefore.Visible      = true;
                txtDifference.Visible          = true;
                txtQuantityNow.Visible         = true;
                txtMinThreshold.Visible        = true;
                txtMaxThreshold.Visible        = true;
                imgProductHistory.Visible      = true;
                imgProductPriceHistory.Visible = true;
                imgChangePrice.Visible         = true;
                imgEditNow.Visible             = true;

                Products       clsProduct        = new Products();
                ProductDetails clsProductDetails = clsProduct.Details1(int.Parse(cboBranch.SelectedItem.Value), Convert.ToInt64(cboProductCode.SelectedValue));

                txtProductCode.Text     = cboProductCode.SelectedItem.Text;
                lblProductDesc.Text     = clsProductDetails.ProductDesc;
                lblUnitName.ToolTip     = clsProductDetails.BaseUnitID.ToString();
                lblUnitName.Text        = clsProductDetails.BaseUnitCode;
                txtQuantityBefore.Text  = clsProductDetails.Quantity.ToString("#,##0.#0");
                txtDifference.Text      = "0";
                txtQuantityNow.Text     = txtQuantityBefore.Text;
                txtMinThreshold.ToolTip = clsProductDetails.MinThreshold.ToString("#,##0.#0");
                txtMinThreshold.Text    = clsProductDetails.MinThreshold.ToString("#,##0.#0");
                txtMaxThreshold.ToolTip = clsProductDetails.MaxThreshold.ToString("#,##0.#0");
                txtMaxThreshold.Text    = clsProductDetails.MaxThreshold.ToString("#,##0.#0");

                ProductInventories clsProductInventory = new ProductInventories(clsProduct.Connection, clsProduct.Transaction);
                lstVariationMatrix.DataSource = clsProductInventory.ListAsDataTable(int.Parse(cboBranch.SelectedItem.Value), Convert.ToInt64(cboProductCode.SelectedValue)).DefaultView;
                lstVariationMatrix.DataBind();

                clsProduct.CommitAndDispose();

                lstVariationMatrix.Visible = true;
                txtDifference.Enabled      = false;
                txtQuantityNow.Enabled     = false;
                txtMinThreshold.Enabled    = false;
                txtMaxThreshold.Enabled    = false;
            }
        }
Exemple #19
0
        private void LoadList()
        {
            string SortField = "ProductDesc";

            if (Request.QueryString["sortfield"] != null)
            {
                SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);
            }

            SortOption sortoption = SortOption.Ascending;

            if (Request.QueryString["sortoption"] != null)
            {
                sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);
            }

            string stSearchKey = string.Empty;

            if (Request.QueryString["Search"] != null)
            {
                stSearchKey = Server.UrlDecode(Common.Decrypt((string)Request.QueryString["search"], Session.SessionID));
            }
            else if (Session["Search"] != null)
            {
                stSearchKey = Server.UrlDecode(Common.Decrypt(Session["Search"].ToString(), Session.SessionID));
            }

            try { Session.Remove("Search"); }
            catch { }
            if (stSearchKey == null)
            {
                stSearchKey = string.Empty;
            }
            else if (stSearchKey != string.Empty)
            {
                Session.Add("Search", Common.Encrypt(stSearchKey, Session.SessionID));
            }

            string strProductCode       = txtProductCode.Text;
            int    intBranchID          = int.Parse(cboBranch.SelectedItem.Value);
            long   lngSupplierID        = long.Parse(cboContact.SelectedItem.Value);
            long   lngProductGroupID    = long.Parse(cboProductGroup.SelectedItem.Value);
            long   lngProductSubGroupID = long.Parse(cboSubGroup.SelectedItem.Value);


            ProductInventories clsProduct = new ProductInventories();

            System.Data.DataTable dt = clsProduct.ListAsDataTable(BranchID: intBranchID, BarCode: stSearchKey, ProductCode: strProductCode, ProductGroupID: lngProductGroupID, ProductSubGroupID: lngProductSubGroupID, SupplierID: lngSupplierID, Limit: 100, SortField: SortField, SortOrder: SortOption.Ascending);
            clsProduct.CommitAndDispose();

            PageData.DataSource = dt.DefaultView;

            int iPageSize = Convert.ToInt16(Session["PageSize"]);

            PageData.AllowPaging = true;
            PageData.PageSize    = iPageSize;
            try
            {
                PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }
            catch
            {
                PageData.CurrentPageIndex = 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }

            cboCurrentPage.Items.Clear();
            for (int i = 0; i < PageData.PageCount; i++)
            {
                int iValue = i + 1;
                cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString()));
                if (PageData.CurrentPageIndex == i)
                {
                    cboCurrentPage.Items[i].Selected = true;
                }
                else
                {
                    cboCurrentPage.Items[i].Selected = false;
                }
            }
            lblDataCount.Text = " of " + " " + PageData.PageCount;
        }