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; } }
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; }
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; } }
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(); } } }
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(); }
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); }
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 = "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; }
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; }