private void SaveAllActualQuantity()
 {
     HtmlInputCheckBox chkMatrixID = null;
     HtmlInputCheckBox chkList = null;
     TextBox txtActualQuantity = null;
     int intBranchID = int.Parse(cboBranch.SelectedItem.Value);
     ProductInventories clsProductInventories = new ProductInventories();
     foreach (DataListItem item in lstItem.Items)
     {
         txtActualQuantity = (TextBox)item.FindControl("txtActualQuantity");
         chkList = (HtmlInputCheckBox)item.FindControl("chkList");
         chkMatrixID = (HtmlInputCheckBox)item.FindControl("chkMatrixID");
         try
         {
             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();
 }
        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.CloseInventoryByProductGroup(int.Parse(cboBranch.SelectedItem.Value), clsAccessUserDetails.UID, DateTime.Parse(txtClosingDate.Text), strReferenceNo, long.Parse(cboProductGroup.SelectedItem.Value), cboProductGroup.SelectedItem.Text);

                    Products clsProducts = new Products(clsERPConfig.Connection, clsERPConfig.Transaction);
                    clsProducts.LockUnlockForSellingByProductGroup(int.Parse(cboBranch.SelectedItem.Value), long.Parse(cboProductGroup.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;
        }
        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 lngProductGroupID = Convert.ToInt64(cboProductGroup.SelectedItem.Value);

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

            ProductGroup clsProductGroup = new ProductGroup(clsProductInventories.Connection, clsProductInventories.Transaction);
            ProductGroupDetails clsProductGroupDetails = clsProductGroup.Details(lngProductGroupID);

            clsProductInventories.CommitAndDispose();

            PageData.DataSource = dt.DefaultView;

            if (!clsProductGroupDetails.isLock)
            {
                cmdLockUnlockProduct.Text = "Lock Product Group [<label class='ms-error'>Note:</label>Products under this group are <u>CURRENTLY ALLOWED</u> for Selling]";
                cmdLockUnlockProduct.ToolTip = "unlock";
            }
            else
            {
                cmdLockUnlockProduct.Text = "UnLock Product Group [<label class='ms-error'>Note:</label>Products under this group 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;
        }
Beispiel #4
0
        public void GenerateItemsForReorderByRID(Int32 TerminalID, long POID, long RID, DateTime IDC_StartDate, DateTime IDC_EndDate)
        {
            try
            {
                GetConnection();

                Terminal clsTerminal = new Terminal(base.Connection, base.Transaction);
                TerminalDetails clsTerminalDetails = clsTerminal.Details(TerminalID);

                PODetails clsPODetails = Details(POID);

                Products clsProduct = new Products(base.Connection, base.Transaction);
                // Aug 26, 2011  :Lemu
                // Insert UpdateProductReorderOverStockPerSupplier to update the MinThreshold & MaxThreshold using RID before getting the for stocking
                clsProduct.UpdateProductReorderOverStockPerSupplier(clsPODetails.SupplierID, RID, IDC_StartDate, IDC_EndDate);
                // end

                POItem clsPOItem = new POItem(base.Connection, base.Transaction);

                ProductInventories clsProductInventories = new ProductInventories(base.Connection, base.Transaction);
                System.Data.DataTable dt = clsProductInventories.ListAsDataTable(BranchID: Constants.BRANCH_ID_MAIN, SupplierID: clsPODetails.SupplierID, ForReorder: 1);

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    if (decimal.Round(Convert.ToDecimal(dr["RIDReorderQty"].ToString())) > 0)
                    {
                        POItemDetails clsDetails = new POItemDetails();

                        clsDetails.POID = POID;
                        clsDetails.ProductID = Convert.ToInt64(dr["ProductID"].ToString());
                        clsDetails.ProductCode = dr["ProductCode"].ToString();
                        clsDetails.BarCode = dr["BarCode"].ToString();
                        clsDetails.Description = dr["ProductDesc"].ToString();
                        clsDetails.ProductGroup = dr["ProductGroupCode"].ToString();
                        clsDetails.ProductSubGroup = dr["ProductSubGroupCode"].ToString();
                        clsDetails.ProductUnitID = Convert.ToInt32(dr["UnitID"]);
                        clsDetails.ProductUnitCode = dr["UnitName"].ToString();
                        clsDetails.RID = Convert.ToInt64(dr["RID"]);
                        clsDetails.Quantity = decimal.Round(Convert.ToDecimal(dr["RIDReorderQty"]));
                        clsDetails.UnitCost = Convert.ToDecimal(dr["PurchasePrice"]);
                        clsDetails.Discount = 0;
                        clsDetails.DiscountApplied = 0;
                        clsDetails.DiscountType = DiscountTypes.Percentage;
                        clsDetails.Remarks = "added using auto generation";

                        decimal amount = clsDetails.Quantity * clsDetails.UnitCost;


                        // Added Sep 27, 2010 4:20PM : for selling information
                        clsDetails.SellingPrice = decimal.Parse(dr["Price"].ToString());
                        clsDetails.SellingVAT = clsTerminalDetails.VAT;
                        clsDetails.SellingEVAT = clsTerminalDetails.EVAT;
                        clsDetails.SellingLocalTax = clsTerminalDetails.LocalTax;
                        clsDetails.OldSellingPrice = clsDetails.SellingPrice;

                        if (Convert.ToDecimal(dr["VAT"]) > 0)
                        {
                            clsDetails.VatableAmount = amount;
                            clsDetails.EVatableAmount = amount;
                            clsDetails.LocalTax = amount;

                            clsDetails.VatableAmount = (clsDetails.VatableAmount) / (1 + (clsTerminalDetails.VAT / 100));
                            clsDetails.EVatableAmount = (clsDetails.EVatableAmount) / (1 + (clsTerminalDetails.VAT / 100));
                            clsDetails.LocalTax = (clsDetails.LocalTax) / (1 + (clsTerminalDetails.LocalTax / 100));
                            clsDetails.IsVatable = true;
                        }
                        else
                        {
                            clsDetails.VAT = 0;
                            clsDetails.VatableAmount = 0;
                            clsDetails.EVAT = 0;
                            clsDetails.EVatableAmount = 0;
                            clsDetails.LocalTax = 0;
                            clsDetails.IsVatable = false;
                        }
                        clsDetails.Amount = amount;

                        clsDetails.VariationMatrixID = Convert.ToInt64(dr["MatrixID"]);
                        clsDetails.MatrixDescription = dr["MatrixDescription"].ToString();
                        clsPOItem.Insert(clsDetails);
                    }
                }
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
		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;

			}
        }
		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);
		}
		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);
		}
        private void LoadList()
        {
            string SortField = "ProductSubGroupCode ASC, prd.SequenceNo ";
            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 lngProductGroupID = Convert.ToInt64(cboProductGroup.SelectedItem.Value);

            ProductInventories clsProductInventories = new ProductInventories();
            System.Data.DataTable dt = clsProductInventories.ListAsDataTable(BranchID: int.Parse(cboBranch.SelectedItem.Value), ProductGroupID: lngProductGroupID, clsProductListFilterType: ProductListFilterType.ShowActiveOnly, SortField: SortField, SortOrder: (sortoption == SortOption.Ascending ? SortOption.Ascending : 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;
        }
        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;
            }
        }
		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;

			}
        }
Beispiel #11
0
        private void ShowProductPerBranchQuantity()
        {
            try
            {
                if (mclsSysConfigDetails.WillShowProductBranchQuantityInItemSelect)
                {
                    if (dgItems.CurrentRowIndex < 0)
                    {
                        dgvItemsPerBranch.Visible = false;
                    }
                    else
                    {
                        ProductModel.ProductID = Int64.Parse(dgItems[dgItems.CurrentRowIndex, 1].ToString());
                        ProductModel.MatrixID = Int64.Parse(dgItems[dgItems.CurrentRowIndex, 2].ToString());

                        ProductInventories clsProduct = new ProductInventories();
                        System.Data.DataTable dt = clsProduct.ListAsDataTable(ProductID: ProductModel.ProductID, MatrixID: ProductModel.MatrixID, isSummary: 0);
                        clsProduct.CommitAndDispose();

                        dgvItemsPerBranch.MultiSelect = false;
                        dgvItemsPerBranch.AutoGenerateColumns = true;
                        dgvItemsPerBranch.AutoSize = false;
                        dgvItemsPerBranch.DataSource = dt.TableName;
                        dgvItemsPerBranch.DataSource = dt;

                        foreach (DataGridViewColumn dc in dgvItemsPerBranch.Columns)
                        {
                            dc.Visible = false;
                        }

                        dgvItemsPerBranch.Columns["BranchCode"].Visible = true;
                        dgvItemsPerBranch.Columns["Quantity"].Visible = true;
                        dgvItemsPerBranch.Columns["ConvertedQuantity"].Visible = true;

                        dgvItemsPerBranch.Columns["BranchCode"].DisplayIndex = 0;
                        dgvItemsPerBranch.Columns["Quantity"].DisplayIndex = 1;
                        dgvItemsPerBranch.Columns["ConvertedQuantity"].DisplayIndex = 2;

                        dgvItemsPerBranch.Columns["BranchCode"].Width = 170;
                        dgvItemsPerBranch.Columns["Quantity"].Width = 75;
                        dgvItemsPerBranch.Columns["ConvertedQuantity"].Width = 90;

                        dgvItemsPerBranch.Columns["BranchCode"].HeaderText = "Branch";
                        dgvItemsPerBranch.Columns["Quantity"].HeaderText = "Quantity";
                        dgvItemsPerBranch.Columns["ConvertedQuantity"].HeaderText = "Converted Qty";

                        dgvItemsPerBranch.Columns["Quantity"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                        dgvItemsPerBranch.Columns["ConvertedQuantity"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;

                        dgvItemsPerBranch.Columns["Quantity"].DefaultCellStyle.Format = "#,##0.#0";

                        dgvItemsPerBranch.ReadOnly = true;

                        dgvItemsPerBranch.Height = dt.Rows.Count * 30;
                        dgvItemsPerBranch.Left = dgItems.Width - 480;
                        if (dgItems.GetCurrentCellBounds().Y  >= 500)
                            dgvItemsPerBranch.Top = dgItems.GetCurrentCellBounds().Y + 50 - dgvItemsPerBranch.Height;
                        else
                            dgvItemsPerBranch.Top = dgItems.GetCurrentCellBounds().Y + 105;

                        dgvItemsPerBranch.Visible = true;
                    }
                }
                else
                {
                    dgvItemsPerBranch.Visible = false;
                }
            }
            catch { }
        }
		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);
		}
Beispiel #13
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();
                }
			}
		}				
Beispiel #14
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;
        }