private void LoadOptions() { DataClass clsDataClass = new DataClass(); lblProductID.Text = Common.Decrypt((string)Request.QueryString["prodid"], Session.SessionID); lblMatrixID.Text = Common.Decrypt(Request.QueryString["id"], Session.SessionID); ProductVariations clsProductVariation = new ProductVariations(); lstItem.DataSource = clsProductVariation.ListAsDataTable(Convert.ToInt64(lblProductID.Text)).DefaultView; lstItem.DataBind(); clsProductVariation.CommitAndDispose(); ProductUnitsMatrix clsProductUnitsMatrix = new ProductUnitsMatrix(); cboUnit.DataTextField = "BottomUnitName"; cboUnit.DataValueField = "BottomUnitID"; cboUnit.DataSource = clsProductUnitsMatrix.ListAsDataTable(Convert.ToInt64(lblProductID.Text)).DefaultView; cboUnit.DataBind(); cboUnit.SelectedIndex = cboUnit.Items.Count - 1; clsProductUnitsMatrix.CommitAndDispose(); Products clsProduct = new Products(); ProductDetails clsDetails = clsProduct.Details(Convert.ToInt64(lblProductID.Text)); cboUnit.Items.Add(new ListItem(clsDetails.BaseUnitName, clsDetails.BaseUnitID.ToString())); clsProduct.CommitAndDispose(); cboUnit.SelectedIndex = cboUnit.Items.Count - 1; lblProductSubGroupID.Text = clsDetails.ProductSubGroupID.ToString(); string stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&prodid=" + Common.Encrypt(lblProductID.Text, Session.SessionID); lnkVariations.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_Variations/Default.aspx" + stParam; }
private void LoadOptions() { lblProductID.Text = Common.Decrypt((string)Request.QueryString["prodid"], Session.SessionID); lblMatrixID.Text = Common.Decrypt(Request.QueryString["id"], Session.SessionID); ProductVariations clsProductVariation = new ProductVariations(); lstItem.DataSource = clsProductVariation.ListAsDataTable(Convert.ToInt64(lblProductID.Text)).DefaultView; lstItem.DataBind(); ProductUnitsMatrix clsUnit = new ProductUnitsMatrix(clsProductVariation.Connection, clsProductVariation.Transaction); cboUnit.DataTextField = "BottomUnitName"; cboUnit.DataValueField = "BottomUnitID"; cboUnit.DataSource = clsUnit.ListAsDataTable(Convert.ToInt64(lblProductID.Text)).DefaultView; cboUnit.DataBind(); Products clsProduct = new Products(clsProductVariation.Connection, clsProductVariation.Transaction); ProductDetails clsDetails = clsProduct.Details(Convert.ToInt64(lblProductID.Text)); cboUnit.Items.Add(new ListItem(clsDetails.BaseUnitName, clsDetails.BaseUnitID.ToString())); clsProductVariation.CommitAndDispose(); cboUnit.SelectedIndex = cboUnit.Items.Count - 1; }
private bool Delete() { bool boRetValue = false; string stIDs = ""; foreach (DataListItem item in lstItem.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList"); if (chkList != null) { if (chkList.Checked == true) { stIDs += chkList.Value + ","; boRetValue = true; } } } if (boRetValue) { ProductVariations clsProductVariation = new ProductVariations(); clsProductVariation.Delete(Convert.ToInt16(lblProductID.Text), stIDs.Substring(0, stIDs.Length - 1)); clsProductVariation.CommitAndDispose(); } return(boRetValue); }
private void LoadOptions() { lblProductID.Text = Common.Decrypt((string)Request.QueryString["prodid"], Session.SessionID); ProductVariations clsProductVariation = new ProductVariations(); lstItem.DataSource = clsProductVariation.ListAsDataTable(Convert.ToInt64(lblProductID.Text)).DefaultView; lstItem.DataBind(); clsProductVariation.CommitAndDispose(); ProductUnitsMatrix clsUnit = new ProductUnitsMatrix(); cboUnit.DataTextField = "BottomUnitName"; cboUnit.DataValueField = "BottomUnitID"; cboUnit.DataSource = clsUnit.ListAsDataTable(Convert.ToInt64(lblProductID.Text)).DefaultView; cboUnit.DataBind(); cboUnit.SelectedIndex = cboUnit.Items.Count - 1; clsUnit.CommitAndDispose(); Products clsProduct = new Products(); ProductDetails clsProductDetails = clsProduct.Details(Convert.ToInt64(lblProductID.Text)); lblProductSubGroupID.Text = clsProductDetails.ProductSubGroupID.ToString(); cboUnit.Items.Add(new ListItem(clsProductDetails.BaseUnitName, clsProductDetails.BaseUnitID.ToString())); cboUnit.SelectedIndex = cboUnit.Items.IndexOf(cboUnit.Items.FindByValue(clsProductDetails.BaseUnitID.ToString())); txtProductPrice.Text = clsProductDetails.Price.ToString("#,##0.#0"); txtPrice1.Text = clsProductDetails.Price1.ToString("#,##0.#0"); txtPrice2.Text = clsProductDetails.Price2.ToString("#,##0.#0"); txtPrice3.Text = clsProductDetails.Price3.ToString("#,##0.#0"); txtPrice4.Text = clsProductDetails.Price4.ToString("#,##0.#0"); txtPrice5.Text = clsProductDetails.Price5.ToString("#,##0.#0"); txtWSPrice.Text = clsProductDetails.WSPrice.ToString("#,##0.#0"); txtPurchasePrice.Text = clsProductDetails.PurchasePrice.ToString("#,##0.#0"); decimal decMargin = clsProductDetails.Price - clsProductDetails.PurchasePrice; try { decMargin = decMargin / clsProductDetails.PurchasePrice; } catch { decMargin = 1; } decMargin = decMargin * 100; txtMargin.Text = decMargin.ToString("#,##0.##0"); decMargin = clsProductDetails.WSPrice - clsProductDetails.PurchasePrice; try { decMargin = decMargin / clsProductDetails.PurchasePrice; } catch { decMargin = 1; } decMargin = decMargin * 100; txtWSPriceMarkUp.Text = decMargin.ToString("#,##0.##0"); chkIncludeInSubtotalDiscount.Checked = clsProductDetails.IncludeInSubtotalDiscount; txtVAT.Text = clsProductDetails.VAT.ToString("#,##0.#0"); txtEVAT.Text = clsProductDetails.EVAT.ToString("#,##0.#0"); clsProduct.CommitAndDispose(); string stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&prodid=" + Common.Encrypt(lblProductID.Text, Session.SessionID); lnkVariations.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_Variations/Default.aspx" + stParam; }
private void SaveRecord() { ProductVariations clsProductVariation = new ProductVariations(); ProductVariationDetails clsDetails = new ProductVariationDetails(); clsDetails.ProductID = Convert.ToInt32(lblProductID.Text); clsDetails.VariationID = Convert.ToInt32(cboVariationType.SelectedItem.Value); clsProductVariation.Update(clsDetails, Convert.ToInt32(lblProductVariationID.Text)); clsProductVariation.CommitAndDispose(); }
private void EasyAddSaveRecord() { ProductVariationDetails clsDetails = new ProductVariationDetails(); clsDetails.ProductID = Convert.ToInt64(lblProductID.Text); clsDetails.VariationID = Convert.ToInt32(cboVariationType.SelectedItem.Value); clsDetails.VariationType = cboVariationType.SelectedItem.Text; ProductVariations clsProductVariations = new ProductVariations(); int id = clsProductVariations.Insert(clsDetails); clsProductVariations.CommitAndDispose(); }
private void SaveVariation(long ProductID, int VariationID, string VariationType) { ProductVariationDetails clsDetails = new ProductVariationDetails(); clsDetails.ProductID = ProductID; clsDetails.VariationID = VariationID; clsDetails.VariationType = VariationType; ProductVariations clsProdVariation = new ProductVariations(); int id = clsProdVariation.Insert(clsDetails); clsProdVariation.CommitAndDispose(); }
public void LoadOptions() { DataClass clsDataClass = new DataClass(); //lblProductID.Text = "0"; // Common.Decrypt((string)Request.QueryString["prodid"], Session.SessionID); ProductVariations clsVariation = new ProductVariations(); cboVariationType.DataTextField = "VariationType"; cboVariationType.DataValueField = "VariationID"; cboVariationType.DataSource = clsDataClass.DataReaderToDataTable(clsVariation.AvailableVariations(Convert.ToInt32(lblProductID.Text), "VariationType", SortOption.Ascending)).DefaultView; cboVariationType.DataBind(); cboVariationType.SelectedIndex = cboVariationType.Items.Count - 1; clsVariation.CommitAndDispose(); }
/// <summary> /// Sorts the ProductVariations VariantId by toggling Tab3VariantIdsOrder int /// </summary> public void SortTab3VariantIds() { List <KeyValuePair <string, string> > SortedList = new List <KeyValuePair <string, string> >(); if (Tab3VariantIdsOrder == 0) { SortedList = ProductVariations.OrderByDescending(o => o.Key).ToList(); Tab3VariantIdsOrder = 1; } else { SortedList = ProductVariations.OrderBy(o => o.Key).ToList(); Tab3VariantIdsOrder = 0; } this.ProductVariations = SortedList; }
private void SaveRecord() { long lngProductGroupID = long.Parse(cboProductGroup.SelectedItem.Value); long lngProductSubGroupID = long.Parse(cboProductSubGroup.SelectedItem.Value); long lngProductID = long.Parse(cboProductCode.SelectedItem.Value); long lngVariationID = long.Parse(cboVariationType.SelectedItem.Value); string javaScript = ""; if (lngVariationID == 0) { javaScript = "window.alert('Please select at least one variation to add.')"; System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.updSave, this.updSave.GetType(), "openwindow", javaScript, true); } else { ProductVariations clsProductVariation = new ProductVariations(); clsProductVariation.AddEasyVariation(lngProductGroupID, lngProductSubGroupID, lngProductID, lngVariationID, Convert.ToString(Session["Name"])); clsProductVariation.CommitAndDispose(); javaScript = "window.alert('Variation has been saved.')"; System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.updSave, this.updSave.GetType(), "openwindow", javaScript, true); } }
private void LoadOptions() { DataClass clsDataClass = new DataClass(); lblProductID.Text = Common.Decrypt((string)Request.QueryString["prodid"], Session.SessionID); lblProductVariationID.Text = Common.Decrypt(Request.QueryString["id"], Session.SessionID); Variation clsVariation = new Variation(); string VariationType = clsVariation.Details(Convert.ToInt32(lblProductVariationID.Text)).VariationType; clsVariation.CommitAndDispose(); ProductVariations clsProductVariation = new ProductVariations(); cboVariationType.DataTextField = "VariationType"; cboVariationType.DataValueField = "VariationID"; cboVariationType.DataSource = clsDataClass.DataReaderToDataTable(clsProductVariation.AvailableVariations(Convert.ToInt16(lblProductID.Text), "VariationType", SortOption.Ascending)).DefaultView; cboVariationType.DataBind(); cboVariationType.Items.Add(new ListItem(VariationType, lblProductVariationID.Text)); cboVariationType.SelectedIndex = cboVariationType.Items.Count - 1; clsProductVariation.CommitAndDispose(); }
private void ExportToFile() { TransferOut clsTransferOut = new TransferOut(); TransferOutDetails clsTransferOutDetails = clsTransferOut.Details(long.Parse(lblTransferOutID.Text)); TransferOutItem clsTransferOutItem = new TransferOutItem(clsTransferOut.Connection, clsTransferOut.Transaction); DataTable dtaTransferOutItems = clsTransferOutItem.ListAsDataTable(clsTransferOutDetails.TransferOutID, null, SortOption.Ascending); Branch clsBranch = new Branch(clsTransferOut.Connection, clsTransferOut.Transaction); BranchDetails clsBranchDetails; Contacts clsContact = new Contacts(clsTransferOut.Connection, clsTransferOut.Transaction); ContactDetails clsContactDetails; Products clsProduct = new Products(clsTransferOut.Connection, clsTransferOut.Transaction); ProductDetails clsProductDetails; ProductVariations clsProductVariation = new ProductVariations(clsTransferOut.Connection, clsTransferOut.Transaction); DataTable dtaProductVariation; ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsTransferOut.Connection, clsTransferOut.Transaction); DataTable dtaProductVariationsMatrix; string xmlFileName = Server.MapPath(@"\RetailPlus\temp\" + lblBranchCode.Text.Replace(" ", "").Trim() + "_" + clsTransferOutDetails.TransferOutNo + "_" + clsTransferOutDetails.TransferOutDate.ToString("yyyyMMddHHmmssffff") + ".xml"); XmlTextWriter writer = new XmlTextWriter(xmlFileName, System.Text.Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteComment("This file represents the TransferOut Details of TransferOut No: '" + clsTransferOutDetails.TransferOutNo + "' for " + lblBranchCode.Text + " branch."); writer.WriteComment("Save this in your local file. Goto 'File', click 'Save As', select the location in your local directory, click 'Save'."); writer.WriteStartElement("TransferOutDetails"); writer.WriteAttributeString("TransferOutID", XmlConvert.ToString(clsTransferOutDetails.TransferOutID)); writer.WriteAttributeString("TransferOutNo", clsTransferOutDetails.TransferOutNo); writer.WriteAttributeString("TransferOutDate", clsTransferOutDetails.TransferOutDate.ToString("MM/dd/yyyy HH:mm:ss")); /******Supplier information******/ clsContactDetails = clsContact.Details(clsTransferOutDetails.SupplierID); writer.WriteAttributeString("SupplierID", XmlConvert.ToString(clsContactDetails.ContactID)); writer.WriteAttributeString("SupplierCode", clsContactDetails.ContactCode); writer.WriteAttributeString("SupplierName", clsContactDetails.ContactName); writer.WriteAttributeString("SupplierContact", clsContactDetails.BusinessName); writer.WriteAttributeString("SupplierAddress", clsTransferOutDetails.SupplierAddress); writer.WriteAttributeString("SupplierTelephoneNo", clsTransferOutDetails.SupplierTelephoneNo); writer.WriteAttributeString("SupplierModeOfTerms", XmlConvert.ToString(clsTransferOutDetails.SupplierModeOfTerms)); writer.WriteAttributeString("SupplierTerms", XmlConvert.ToString(clsTransferOutDetails.SupplierTerms)); writer.WriteAttributeString("SupplierContactGroupName", clsContactDetails.ContactGroupName); /******End Of Supplier Information******/ writer.WriteAttributeString("RequiredDeliveryDate", clsTransferOutDetails.RequiredDeliveryDate.ToString("MM/dd/yyyy HH:mm:ss")); /******Branch & Transferrer Information******/ clsBranchDetails = clsBranch.Details(short.Parse(clsTransferOutDetails.BranchID.ToString())); writer.WriteAttributeString("BranchID", XmlConvert.ToString(clsTransferOutDetails.BranchID)); writer.WriteAttributeString("BranchCode", clsTransferOutDetails.BranchCode); writer.WriteAttributeString("BranchName", clsTransferOutDetails.BranchName); writer.WriteAttributeString("BranchAddress", clsTransferOutDetails.BranchAddress); writer.WriteAttributeString("BranchDBIP", clsBranchDetails.DBIP); writer.WriteAttributeString("BranchDBPort", clsBranchDetails.DBPort); writer.WriteAttributeString("BranchRemarks", clsBranchDetails.Remarks); writer.WriteAttributeString("TransferrerID", clsTransferOutDetails.TransferrerID.ToString()); writer.WriteAttributeString("TransferrerName", clsTransferOutDetails.TransferrerName); /******End Of Branch & Transferrer Information******/ /******Amount Information******/ writer.WriteAttributeString("SubTotal", XmlConvert.ToString(clsTransferOutDetails.SubTotal)); writer.WriteAttributeString("Discount", XmlConvert.ToString(clsTransferOutDetails.Discount)); writer.WriteAttributeString("DiscountApplied", XmlConvert.ToString(clsTransferOutDetails.DiscountApplied)); writer.WriteAttributeString("DiscountType", clsTransferOutDetails.DiscountType.ToString("d")); writer.WriteAttributeString("VAT", XmlConvert.ToString(clsTransferOutDetails.VAT)); writer.WriteAttributeString("VatableAmount", XmlConvert.ToString(clsTransferOutDetails.VatableAmount)); writer.WriteAttributeString("EVAT", XmlConvert.ToString(clsTransferOutDetails.EVAT)); writer.WriteAttributeString("EVatableAmount", XmlConvert.ToString(clsTransferOutDetails.EVatableAmount)); writer.WriteAttributeString("LocalTax", XmlConvert.ToString(clsTransferOutDetails.LocalTax)); writer.WriteAttributeString("Freight", XmlConvert.ToString(clsTransferOutDetails.Freight)); writer.WriteAttributeString("Deposit", XmlConvert.ToString(clsTransferOutDetails.Deposit)); writer.WriteAttributeString("UnpaidAmount", XmlConvert.ToString(clsTransferOutDetails.UnpaidAmount)); writer.WriteAttributeString("PaidAmount", XmlConvert.ToString(clsTransferOutDetails.PaidAmount)); writer.WriteAttributeString("TotalItemDiscount", XmlConvert.ToString(clsTransferOutDetails.TotalItemDiscount)); writer.WriteAttributeString("Status", clsTransferOutDetails.Status.ToString("d")); writer.WriteAttributeString("Remarks", clsTransferOutDetails.Remarks); writer.WriteAttributeString("SupplierDRNo", clsTransferOutDetails.SupplierDRNo); writer.WriteAttributeString("DeliveryDate", clsTransferOutDetails.DeliveryDate.ToString("MM/dd/yyyy HH:mm:ss")); writer.WriteAttributeString("CancelledDate", clsTransferOutDetails.CancelledDate.ToString("MM/dd/yyyy HH:mm:ss")); writer.WriteAttributeString("CancelledRemarks", clsTransferOutDetails.CancelledRemarks); writer.WriteAttributeString("CancelledByID", XmlConvert.ToString(clsTransferOutDetails.CancelledByID)); /******End Of Branch Information******/ foreach (DataRow row in dtaTransferOutItems.Rows) { clsProductDetails = new ProductDetails(); clsProductDetails = clsProduct.Details(Convert.ToInt64(row["ProductID"].ToString())); writer.WriteStartElement("TransferOutItem"); writer.WriteAttributeString("TransferOutItemID", row["TransferOutItemID"].ToString()); writer.WriteAttributeString("TransferOutID", row["TransferOutID"].ToString()); writer.WriteAttributeString("ProductID", row["ProductID"].ToString()); /*****Product Information*****/ writer.WriteAttributeString("ProductCode", clsProductDetails.ProductCode); writer.WriteAttributeString("BarCode", clsProductDetails.BarCode); writer.WriteAttributeString("ProductDesc", clsProductDetails.ProductDesc); writer.WriteAttributeString("MatrixDescription", row["MatrixDescription"].ToString()); writer.WriteAttributeString("ProductSubGroupID", clsProductDetails.ProductSubGroupID.ToString()); writer.WriteAttributeString("ProductSubGroupCode", clsProductDetails.ProductSubGroupCode); writer.WriteAttributeString("ProductSubGroupName", clsProductDetails.ProductSubGroupName); writer.WriteAttributeString("ProductGroupID", clsProductDetails.ProductGroupID.ToString()); writer.WriteAttributeString("ProductGroupCode", clsProductDetails.ProductGroupCode); writer.WriteAttributeString("ProductGroupName", clsProductDetails.ProductGroupName); writer.WriteAttributeString("BaseUnitID", clsProductDetails.BaseUnitID.ToString()); writer.WriteAttributeString("BaseUnitCode", clsProductDetails.BaseUnitCode); writer.WriteAttributeString("BaseUnitName", clsProductDetails.BaseUnitName); writer.WriteAttributeString("DateCreated", clsProductDetails.DateCreated.ToString("MM/dd/yy HH:mm:ss")); writer.WriteAttributeString("Deleted", clsProductDetails.Deleted.ToString()); writer.WriteAttributeString("Price", clsProductDetails.Price.ToString()); writer.WriteAttributeString("PurchasePrice", clsProductDetails.PurchasePrice.ToString()); writer.WriteAttributeString("IncludeInSubtotalDiscount", clsProductDetails.IncludeInSubtotalDiscount.ToString()); writer.WriteAttributeString("VAT", clsProductDetails.VAT.ToString()); writer.WriteAttributeString("EVAT", clsProductDetails.EVAT.ToString()); writer.WriteAttributeString("LocalTax", clsProductDetails.LocalTax.ToString()); writer.WriteAttributeString("Quantity", clsProductDetails.Quantity.ToString()); writer.WriteAttributeString("MinThreshold", clsProductDetails.MinThreshold.ToString()); writer.WriteAttributeString("MaxThreshold", clsProductDetails.MaxThreshold.ToString()); writer.WriteAttributeString("ChartOfAccountIDPurchase", clsProductDetails.ChartOfAccountIDPurchase.ToString()); writer.WriteAttributeString("ChartOfAccountIDSold", clsProductDetails.ChartOfAccountIDSold.ToString()); writer.WriteAttributeString("ChartOfAccountIDInventory", clsProductDetails.ChartOfAccountIDInventory.ToString()); writer.WriteAttributeString("ChartOfAccountIDTaxPurchase", clsProductDetails.ChartOfAccountIDTaxPurchase.ToString()); writer.WriteAttributeString("ChartOfAccountIDTaxSold", clsProductDetails.ChartOfAccountIDTaxSold.ToString()); writer.WriteAttributeString("IsItemSold", clsProductDetails.IsItemSold.ToString()); writer.WriteAttributeString("WillPrintProductComposition", clsProductDetails.WillPrintProductComposition.ToString()); writer.WriteAttributeString("UpdatedBy", clsProductDetails.UpdatedBy.ToString()); writer.WriteAttributeString("UpdatedOn", clsProductDetails.UpdatedOn.ToString("MM/dd/yyyy HH:mm")); writer.WriteAttributeString("PercentageCommision", clsProductDetails.PercentageCommision.ToString()); writer.WriteAttributeString("Active", clsProductDetails.Active.ToString()); /*****End Of Product Information*****/ writer.WriteAttributeString("ItemProductGroup", row["ProductGroup"].ToString()); writer.WriteAttributeString("ItemProductSubGroup", row["ProductSubGroup"].ToString()); writer.WriteAttributeString("ItemVariationMatrixID", row["VariationMatrixID"].ToString()); writer.WriteAttributeString("ItemBaseVariationDescription", row["MatrixDescription"].ToString()); writer.WriteAttributeString("ItemProductUnitID", row["ProductUnitID"].ToString()); writer.WriteAttributeString("ItemProductUnitCode", row["ProductUnitCode"].ToString()); writer.WriteAttributeString("ItemQuantity", row["Quantity"].ToString()); writer.WriteAttributeString("ItemUnitCost", row["UnitCost"].ToString()); writer.WriteAttributeString("ItemDiscount", row["Discount"].ToString()); writer.WriteAttributeString("ItemDiscountApplied", row["DiscountApplied"].ToString()); writer.WriteAttributeString("ItemDiscountType", row["DiscountType"].ToString()); writer.WriteAttributeString("ItemAmount", row["Amount"].ToString()); writer.WriteAttributeString("ItemVAT", row["VAT"].ToString()); writer.WriteAttributeString("ItemVatableAmount", row["VatableAmount"].ToString()); writer.WriteAttributeString("ItemEVAT", row["EVAT"].ToString()); writer.WriteAttributeString("ItemEVatableAmount", row["EVatableAmount"].ToString()); writer.WriteAttributeString("ItemLocalTax", row["LocalTax"].ToString()); writer.WriteAttributeString("ItemisVATInclusive", row["isVATInclusive"].ToString()); writer.WriteAttributeString("ItemTransferOutItemStatus", row["TransferOutItemStatus"].ToString()); writer.WriteAttributeString("ItemIsVatable", row["IsVatable"].ToString()); writer.WriteAttributeString("ItemSellingPrice", row["SellingPrice"].ToString()); writer.WriteAttributeString("ItemSellingVAT", row["SellingVAT"].ToString()); writer.WriteAttributeString("ItemSellingEVAT", row["SellingEVAT"].ToString()); writer.WriteAttributeString("ItemSellingLocalTax", row["SellingLocalTax"].ToString()); writer.WriteAttributeString("ItemOldSellingPrice", row["OldSellingPrice"].ToString()); writer.WriteAttributeString("ItemRemarks", row["Remarks"].ToString()); dtaProductVariation = clsProductVariation.ListAsDataTable(clsProductDetails.ProductID, null, System.Data.SqlClient.SortOrder.Ascending); foreach (DataRow rowVariation in dtaProductVariation.Rows) { writer.WriteStartElement("Variation", null); writer.WriteAttributeString("VariationCode", rowVariation["VariationCode"].ToString()); writer.WriteAttributeString("VariationType", rowVariation["VariationType"].ToString()); writer.WriteEndElement(); } dtaProductVariationsMatrix = clsProductVariationsMatrix.ProductVariationsMatrixListAsDataTable(long.Parse(row["VariationMatrixID"].ToString()), null, System.Data.SqlClient.SortOrder.Ascending); foreach (DataRow rowVariationsMatrix in dtaProductVariationsMatrix.Rows) { writer.WriteStartElement("VariationMatrix", null); writer.WriteAttributeString("MatriXID", rowVariationsMatrix["MatriXID"].ToString()); writer.WriteAttributeString("VariationID", rowVariationsMatrix["VariationID"].ToString()); writer.WriteAttributeString("Description", rowVariationsMatrix["Description"].ToString()); writer.WriteAttributeString("VariationCode", rowVariationsMatrix["VariationCode"].ToString()); writer.WriteAttributeString("VariationType", rowVariationsMatrix["VariationType"].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); //Write the XML to file and close the writer writer.Flush(); writer.Close(); clsTransferOut.CommitAndDispose(); string stScript = "<Script>"; stScript += "window.open('/RetailPlus/temp/" + lblBranchCode.Text.Replace(" ", "").Trim() + "_" + clsTransferOutDetails.TransferOutNo + "_" + clsTransferOutDetails.TransferOutDate.ToString("yyyyMMddHHmmssffff") + ".xml')"; stScript += "</Script>"; Response.Write(stScript); }
private void LoadList() { ProductVariations clsProductVariation = new ProductVariations(); DataClass clsDataClass = new DataClass(); string SortField = "a.VariationID"; 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); } if (Request.QueryString["Search"] == null) { PageData.DataSource = clsProductVariation.ListAsDataTable(Convert.ToInt64(lblProductID.Text), SortField, sortoption == SortOption.Ascending ? System.Data.SqlClient.SortOrder.Ascending : System.Data.SqlClient.SortOrder.Descending).DefaultView; } else { string SearchKey = Common.Decrypt((string)Request.QueryString["search"], Session.SessionID); PageData.DataSource = clsDataClass.DataReaderToDataTable(clsProductVariation.Search(Convert.ToInt64(lblProductID.Text), SearchKey, SortField, sortoption)).DefaultView; } clsProductVariation.CommitAndDispose(); 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; }
private void Transfer() { Int64 iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["stockid"], Session.SessionID)); Stock clsStock = new Stock(); StockDetails clsStockDetails = clsStock.Details(iID); StockItem clsStockItem = new StockItem(clsStock.Connection, clsStock.Transaction); DataTable dtaStockItemList = clsStockItem.ListAsDataTable(Convert.ToInt64(lblStockID.Text)); Contacts clsContact = new Contacts(clsStock.Connection, clsStock.Transaction); ContactDetails clsContactDetails = clsContact.Details(clsStockDetails.SupplierID); Products clsProduct = new Products(clsStock.Connection, clsStock.Transaction); ProductDetails clsProductDetails; ProductVariations clsProductVariation = new ProductVariations(clsStock.Connection, clsStock.Transaction); DataTable dtaProductVariation; ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsStock.Connection, clsStock.Transaction); DataTable dtaProductVariationsMatrix; string xmlFileName = Server.MapPath(@"\RetailPlus\temp\" + cboBranch.SelectedItem.Text.Replace(" ", "").Trim() + clsStockDetails.TransactionNo + ".xml"); XmlTextWriter writer = new XmlTextWriter(xmlFileName, System.Text.Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteComment("This file represents a new stock transaction for branch: '" + cboBranch.SelectedItem.Text + "'."); writer.WriteComment("Save this in your local file. Goto 'File', click 'Save As', select the location in your local directory, click 'Save'."); writer.WriteStartElement("Stock"); writer.WriteAttributeString("StockID", XmlConvert.ToString(clsStockDetails.StockID)); writer.WriteAttributeString("TransactionNo", clsStockDetails.TransactionNo); writer.WriteAttributeString("StockTypeID", XmlConvert.ToString(clsStockDetails.StockTypeID)); writer.WriteAttributeString("StockTypeCode", clsStockDetails.StockTypeCode); writer.WriteAttributeString("StockTypeDescription", clsStockDetails.StockTypeDescription); writer.WriteAttributeString("StockDirection", clsStockDetails.StockDirection.ToString()); writer.WriteAttributeString("StockDate", clsStockDetails.StockDate.ToString("MM/dd/yyyy HH:mm:ss")); /******Supplier information******/ writer.WriteAttributeString("ContactID", XmlConvert.ToString(clsContactDetails.ContactID)); writer.WriteAttributeString("ContactCode", clsContactDetails.ContactCode); writer.WriteAttributeString("ContactName", clsContactDetails.ContactName); writer.WriteAttributeString("ContactGroupID", clsContactDetails.ContactGroupID.ToString()); writer.WriteAttributeString("ContactGroupName", clsContactDetails.ContactGroupName); writer.WriteAttributeString("ModeOfTerms", clsContactDetails.ModeOfTerms.ToString()); writer.WriteAttributeString("Terms", clsContactDetails.Terms.ToString()); writer.WriteAttributeString("Address", clsContactDetails.Address); writer.WriteAttributeString("BusinessName", clsContactDetails.BusinessName); writer.WriteAttributeString("TelephoneNo", clsContactDetails.TelephoneNo); writer.WriteAttributeString("Remarks", clsContactDetails.Remarks); writer.WriteAttributeString("Debit", clsContactDetails.Debit.ToString()); writer.WriteAttributeString("Credit", clsContactDetails.Credit.ToString()); writer.WriteAttributeString("CreditLimit", clsContactDetails.CreditLimit.ToString()); writer.WriteAttributeString("IsCreditAllowed", clsContactDetails.IsCreditAllowed.ToString()); writer.WriteAttributeString("DateCreated", clsContactDetails.DateCreated.ToString("MM/dd/yy HH:mm:ss")); writer.WriteAttributeString("Deleted", clsContactDetails.Deleted.ToString()); /******End Of Supplier Information******/ writer.WriteAttributeString("StockRemarks", clsStockDetails.Remarks); foreach (DataRow row in dtaStockItemList.Rows) { clsProductDetails = new ProductDetails(); clsProductDetails = clsProduct.Details(Convert.ToInt64(row["ProductID"].ToString())); writer.WriteStartElement("Item"); writer.WriteAttributeString("ItemStockItemID", row["StockItemID"].ToString()); writer.WriteAttributeString("ItemStockID", row["StockID"].ToString()); writer.WriteAttributeString("ItemProductID", row["ProductID"].ToString()); /*****Product Information*****/ writer.WriteAttributeString("ProductCode", clsProductDetails.ProductCode); writer.WriteAttributeString("BarCode", clsProductDetails.BarCode); writer.WriteAttributeString("ProductDesc", clsProductDetails.ProductDesc); writer.WriteAttributeString("ProductSubGroupID", clsProductDetails.ProductSubGroupID.ToString()); writer.WriteAttributeString("ProductSubGroupCode", clsProductDetails.ProductSubGroupCode); writer.WriteAttributeString("ProductSubGroupName", clsProductDetails.ProductSubGroupName); writer.WriteAttributeString("ProductGroupID", clsProductDetails.ProductGroupID.ToString()); writer.WriteAttributeString("ProductGroupCode", clsProductDetails.ProductGroupCode); writer.WriteAttributeString("ProductGroupName", clsProductDetails.ProductGroupName); writer.WriteAttributeString("BaseUnitID", clsProductDetails.BaseUnitID.ToString()); writer.WriteAttributeString("ProductUnitCode", clsProductDetails.BaseUnitCode); writer.WriteAttributeString("ProductUnitName", clsProductDetails.BaseUnitName); writer.WriteAttributeString("DateCreated", clsProductDetails.DateCreated.ToString("MM/dd/yy HH:mm:ss")); writer.WriteAttributeString("Deleted", clsProductDetails.Deleted.ToString()); writer.WriteAttributeString("Price", clsProductDetails.Price.ToString()); writer.WriteAttributeString("PurchasePrice", clsProductDetails.PurchasePrice.ToString()); writer.WriteAttributeString("IncludeInSubtotalDiscount", clsProductDetails.IncludeInSubtotalDiscount.ToString()); writer.WriteAttributeString("VAT", clsProductDetails.VAT.ToString()); writer.WriteAttributeString("EVAT", clsProductDetails.EVAT.ToString()); writer.WriteAttributeString("LocalTax", clsProductDetails.LocalTax.ToString()); writer.WriteAttributeString("Quantity", clsProductDetails.Quantity.ToString()); writer.WriteAttributeString("MinThreshold", clsProductDetails.MinThreshold.ToString()); writer.WriteAttributeString("MaxThreshold", clsProductDetails.MaxThreshold.ToString()); /*****End Of Product Information*****/ writer.WriteAttributeString("ItemVariationMatrixID", row["VariationMatrixID"].ToString()); writer.WriteAttributeString("ItemBaseVariationDescription", row["BaseVariationDescription"].ToString()); writer.WriteAttributeString("ItemProductUnitID", row["ProductUnitID"].ToString()); writer.WriteAttributeString("ItemUnitCode", row["UnitCode"].ToString()); writer.WriteAttributeString("ItemUnitName", row["UnitName"].ToString()); writer.WriteAttributeString("ItemStockTypeID", row["StockTypeID"].ToString()); writer.WriteAttributeString("ItemStockTypeDescription", row["StockTypeDescription"].ToString()); writer.WriteAttributeString("ItemStockDate", row["StockDate"].ToString()); writer.WriteAttributeString("ItemQuantity", row["Quantity"].ToString()); writer.WriteAttributeString("ItemRemarks", row["Remarks"].ToString()); dtaProductVariation = clsProductVariation.ListAsDataTable(clsProductDetails.ProductID, "a.VariationID", System.Data.SqlClient.SortOrder.Ascending); foreach (DataRow rowVariation in dtaProductVariation.Rows) { writer.WriteStartElement("Variation", null); writer.WriteAttributeString("VariationCode", rowVariation["VariationCode"].ToString()); writer.WriteAttributeString("VariationType", rowVariation["VariationType"].ToString()); writer.WriteEndElement(); } dtaProductVariationsMatrix = clsProductVariationsMatrix.ProductVariationsMatrixListAsDataTable(Convert.ToInt64(row["VariationMatrixID"].ToString()), "MatrixID", System.Data.SqlClient.SortOrder.Ascending); foreach (DataRow rowVariationsMatrix in dtaProductVariationsMatrix.Rows) { writer.WriteStartElement("VariationMatrix", null); writer.WriteAttributeString("MatriXID", rowVariationsMatrix["MatriXID"].ToString()); writer.WriteAttributeString("VariationID", rowVariationsMatrix["VariationID"].ToString()); writer.WriteAttributeString("Description", rowVariationsMatrix["Description"].ToString()); writer.WriteAttributeString("VariationCode", rowVariationsMatrix["VariationCode"].ToString()); writer.WriteAttributeString("VariationType", rowVariationsMatrix["VariationType"].ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); //Write the XML to file and close the writer writer.Flush(); writer.Close(); clsStock.CommitAndDispose(); string stScript = "<Script>"; stScript += "window.open('/RetailPlus/temp/" + cboBranch.SelectedItem.Text.Replace(" ", "").Trim() + clsStockDetails.TransactionNo + ".xml')"; stScript += "</Script>"; Response.Write(stScript); }
protected void lstItem_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e) { Common Common = new Common(); HtmlInputCheckBox chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList"); HyperLink lnkProductCode = (HyperLink)e.Item.FindControl("lnkProductCode"); 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)); } else { clsProduct.TagActive(long.Parse(chkList.Value)); } clsProduct.CommitAndDispose(); LoadList(); } break; case "cmdSaveVariationClick": { DropDownList cboVariationType = (DropDownList)e.Item.FindControl("cboVariationType"); SaveVariation(long.Parse(chkList.Value), int.Parse(cboVariationType.SelectedItem.Value), cboVariationType.SelectedItem.Text); ProductVariations clsVariation = new ProductVariations(); cboVariationType.DataTextField = "VariationType"; cboVariationType.DataValueField = "VariationID"; cboVariationType.DataSource = clsVariation.AvailableVariationsDataTable(long.Parse(chkList.Value), "VariationType", SortOption.Ascending).DefaultView; cboVariationType.DataBind(); cboVariationType.SelectedIndex = cboVariationType.Items.Count - 1; clsVariation.CommitAndDispose(); } break; case "imgSaveVariationClick": { DropDownList cboVariationType = (DropDownList)e.Item.FindControl("cboVariationType"); SaveVariation(long.Parse(chkList.Value), int.Parse(cboVariationType.SelectedItem.Value), cboVariationType.SelectedItem.Text); ProductVariations clsVariation = new ProductVariations(); cboVariationType.DataTextField = "VariationType"; cboVariationType.DataValueField = "VariationID"; cboVariationType.DataSource = clsVariation.AvailableVariationsDataTable(long.Parse(chkList.Value), "VariationType", SortOption.Ascending).DefaultView; cboVariationType.DataBind(); cboVariationType.SelectedIndex = cboVariationType.Items.Count - 1; clsVariation.CommitAndDispose(); } break; case "imgVariationsClick": stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_Variations/Default.aspx" + stParam); break; case "imgVariationsMatrixClick": stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_VariationsMatrix/Default.aspx" + stParam); break; case "imgUnitsMatrixClick": stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_UnitsMatrix/Default.aspx" + stParam); break; case "imgVariationsAddClick": stParam = "?task=" + Common.Encrypt("add", Session.SessionID) + "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_Variations/Default.aspx" + stParam); break; case "imgVariationsMatrixAddClick": stParam = "?task=" + Common.Encrypt("add", Session.SessionID) + "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_VariationsMatrix/Default.aspx" + stParam); break; case "imgUnitsMatrixAddClick": stParam = "?task=" + Common.Encrypt("add", Session.SessionID) + "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_UnitsMatrix/Default.aspx" + stParam); break; case "imgPackageMatrixAddClick": stParam = "?task=" + Common.Encrypt("add", Session.SessionID) + "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_Package/Default.aspx" + stParam); break; case "imgInventoryAdjustmentClick": stParam = "?task=" + Common.Encrypt("invadjustment", Session.SessionID) + "&productcode=" + Common.Encrypt(Server.UrlEncode(lnkProductCode.Text), Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/Inventory/Default.aspx" + stParam); break; case "imgProductHistoryClick": stParam = "?task=" + Common.Encrypt("producthistory", Session.SessionID) + "&productcode=" + Common.Encrypt(Server.UrlEncode(lnkProductCode.Text), Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/Reports/Default.aspx" + stParam); break; case "imgProductPriceHistoryClick": stParam = "?task=" + Common.Encrypt("pricehistory", Session.SessionID) + "&productcode=" + Common.Encrypt(Server.UrlEncode(lnkProductCode.Text), Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/Reports/Default.aspx" + stParam); break; case "imgChangePriceClick": stParam = "?task=" + Common.Encrypt("changeprice", Session.SessionID) + "&productcode=" + Common.Encrypt(Server.UrlEncode(lnkProductCode.Text), Session.SessionID); Response.Redirect("Default.aspx" + stParam); break; case "imgFinanceClick": stParam = "?task=" + Common.Encrypt("finance", Session.SessionID) + "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect(Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/Default.aspx" + stParam); break; case "imgEditNowClick": stParam = "?task=" + Common.Encrypt("edit", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID); Response.Redirect("Default.aspx" + stParam); break; } }
protected void lstItem_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Header) { LoadSortFieldOptions(e); } else if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { string stParam = string.Empty; Common Common = new Common(); DataRowView dr = (DataRowView)e.Item.DataItem; HtmlInputCheckBox chkList = (HtmlInputCheckBox)e.Item.FindControl("chkList"); chkList.Value = dr[ProductColumnNames.ProductID].ToString(); ImageButton imgProductTag = (ImageButton)e.Item.FindControl("imgProductTag"); if (Boolean.Parse(dr[ProductColumnNames.Active].ToString())) { imgProductTag.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/prodtagact.gif"; imgProductTag.ToolTip = "Tag this product as INACTIVE."; } else //if (clsProductListFilterType == ProductListFilterType.ShowInactiveOnly) { imgProductTag.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/prodtaginact.gif"; imgProductTag.ToolTip = "Tag this product as ACTIVE."; } //HyperLink lnkVariations = (HyperLink)e.Item.FindControl("lnkVariations"); stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&prodid=" + Common.Encrypt(chkList.Value, Session.SessionID); HyperLink lnkPackage = (HyperLink)e.Item.FindControl("lnkPackage"); lnkPackage.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_Package/Default.aspx" + stParam; HyperLink lnkBarCode = (HyperLink)e.Item.FindControl("lnkBarCode"); lnkBarCode.Text = dr[ProductColumnNames.BarCode].ToString(); lnkBarCode.NavigateUrl = "Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID); HyperLink lnkProductCode = (HyperLink)e.Item.FindControl("lnkProductCode"); lnkProductCode.Text = dr[ProductColumnNames.ProductCode].ToString(); lnkProductCode.NavigateUrl = "Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(chkList.Value, Session.SessionID); HyperLink lnkDescription = (HyperLink)e.Item.FindControl("lnkDescription"); lnkDescription.Text = dr[ProductColumnNames.ProductDesc].ToString(); lnkDescription.NavigateUrl = "Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(dr["ProductID"].ToString(), Session.SessionID); HyperLink lnkGroup = (HyperLink)e.Item.FindControl("lnkGroup"); lnkGroup.Text = dr[ProductColumnNames.ProductGroupCode].ToString(); lnkGroup.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_ProductGroup/Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(dr[ProductColumnNames.ProductGroupID].ToString(), Session.SessionID);; HyperLink lnkUnit = (HyperLink)e.Item.FindControl("lnkUnit"); lnkUnit.Text = dr[ProductColumnNames.BaseUnitCode].ToString(); lnkUnit.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Unit/Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(dr[ProductColumnNames.BaseUnitID].ToString(), Session.SessionID);; Label lblPrice = (Label)e.Item.FindControl("lblPrice"); lblPrice.Text = Convert.ToDecimal(dr[ProductColumnNames.Price].ToString()).ToString("#,##0.#0"); Label lblPurchasePrice = (Label)e.Item.FindControl("lblPurchasePrice"); lblPurchasePrice.Text = Convert.ToDecimal(dr[ProductColumnNames.PurchasePrice].ToString()).ToString("#,##0.#0"); Label lblMargin = (Label)e.Item.FindControl("lblMargin"); decimal decMargin = Convert.ToDecimal(dr[ProductColumnNames.Price].ToString()) - Convert.ToDecimal(dr[ProductColumnNames.PurchasePrice].ToString()); lblMargin.Text = decMargin.ToString("#,##0.##0"); try { decMargin = decMargin / Convert.ToDecimal(dr[ProductColumnNames.PurchasePrice].ToString()); } catch { decMargin = 1; } decMargin = decMargin * 100; lblMargin.Text += " (" + decMargin.ToString("#,##0.##0") + "%)"; Label lnkSubGroup = (Label)e.Item.FindControl("lnkSubGroup"); lnkSubGroup.Text = dr[ProductColumnNames.ProductSubGroupCode].ToString(); Label lblQuantity = (Label)e.Item.FindControl("lblQuantity"); lblQuantity.Text += dr[ProductColumnNames.ConvertedQuantity].ToString(); //if (dr[ProductColumnNames.ConvertedMainQuantity].ToString().Split(';').Length > 0) //{ lblQuantity.Text += " (" + dr[ProductColumnNames.ConvertedMainQuantity].ToString() + ") "; } //else //{ lblQuantity.Text = Convert.ToDecimal(dr[ProductColumnNames.MainQuantity].ToString()).ToString("#,##0.#0"); } HyperLink lnkSupplierName = (HyperLink)e.Item.FindControl("lnkSupplierName"); lnkSupplierName.Text = dr[ProductColumnNames.SupplierName].ToString(); lnkSupplierName.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Contact/Default.aspx" + "?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(dr[ProductColumnNames.SupplierID].ToString(), Session.SessionID); CheckBox chkIncludeInSubtotalDiscount = (CheckBox)e.Item.FindControl("chkIncludeInSubtotalDiscount"); chkIncludeInSubtotalDiscount.Checked = (bool)dr[ProductColumnNames.IncludeInSubtotalDiscount]; Label lblVAT = (Label)e.Item.FindControl("lblVAT"); lblVAT.Text = Convert.ToDecimal(dr[ProductColumnNames.VAT].ToString()).ToString("#,##0.#0") + " %"; Label lblEVAT = (Label)e.Item.FindControl("lblEVAT"); lblEVAT.Text = Convert.ToDecimal(dr[ProductColumnNames.EVAT].ToString()).ToString("#,##0.#0") + " %"; Label lblLocalTax = (Label)e.Item.FindControl("lblLocalTax"); lblLocalTax.Text = Convert.ToDecimal(dr[ProductColumnNames.LocalTax].ToString()).ToString("#,##0.#0") + " %"; //For anchor HtmlGenericControl divInsertVariation = (HtmlGenericControl)e.Item.FindControl("divInsertVariation"); HtmlAnchor imgVariationsAdd = (HtmlAnchor)e.Item.FindControl("imgVariationsAdd"); imgVariationsAdd.HRef = "javascript:ToggleDiv('" + divInsertVariation.ClientID + "')"; DropDownList cboVariationType = (DropDownList)e.Item.FindControl("cboVariationType"); ProductVariations clsVariation = new ProductVariations(); cboVariationType.DataTextField = "VariationType"; cboVariationType.DataValueField = "VariationID"; cboVariationType.DataSource = clsVariation.AvailableVariationsDataTable(long.Parse(chkList.Value), "VariationType", SortOption.Ascending).DefaultView; cboVariationType.DataBind(); cboVariationType.SelectedIndex = cboVariationType.Items.Count - 1; clsVariation.CommitAndDispose(); imgProductTag.Enabled = cmdEdit.Visible; LinkButton cmdSaveVariation = (LinkButton)e.Item.FindControl("cmdSaveVariation"); cmdSaveVariation.Enabled = Convert.ToBoolean(Convert.ToInt16(lblVariationsAccess.Text)); ImageButton imgSaveVariation = (ImageButton)e.Item.FindControl("imgSaveVariation"); imgSaveVariation.Enabled = Convert.ToBoolean(Convert.ToInt16(lblVariationsAccess.Text)); if (!imgSaveVariation.Enabled) { imgSaveVariation.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } ImageButton imgVariations = (ImageButton)e.Item.FindControl("imgVariations"); imgVariations.Enabled = Convert.ToBoolean(Convert.ToInt16(lblVariationsAccess.Text)); if (!imgVariations.Enabled) { imgVariations.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } ImageButton imgVariationsMatrix = (ImageButton)e.Item.FindControl("imgVariationsMatrix"); imgVariationsMatrix.Enabled = Convert.ToBoolean(Convert.ToInt16(lblVariationsAccess.Text)); if (!imgVariationsMatrix.Enabled) { imgVariationsMatrix.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } ImageButton imgUnitsMatrix = (ImageButton)e.Item.FindControl("imgUnitsMatrix"); imgUnitsMatrix.Enabled = Convert.ToBoolean(Convert.ToInt16(lblUnitMatrixAccess.Text)); if (!imgUnitsMatrix.Enabled) { imgUnitsMatrix.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } imgVariationsAdd.Visible = Convert.ToBoolean(Convert.ToInt16(lblVariationsAccess.Text)); ImageButton imgVariationsMatrixAdd = (ImageButton)e.Item.FindControl("imgVariationsMatrixAdd"); imgVariationsMatrixAdd.Enabled = Convert.ToBoolean(Convert.ToInt16(lblVariationsAccess.Text)); if (!imgVariationsMatrixAdd.Enabled) { imgVariationsMatrixAdd.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } ImageButton imgUnitsMatrixAdd = (ImageButton)e.Item.FindControl("imgUnitsMatrixAdd"); imgUnitsMatrixAdd.Enabled = Convert.ToBoolean(Convert.ToInt16(lblUnitMatrixAccess.Text)); if (!imgUnitsMatrixAdd.Enabled) { imgUnitsMatrixAdd.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } lnkPackage.Enabled = Convert.ToBoolean(Convert.ToInt16(lblProductPackageAccess.Text)); if (!lnkPackage.Enabled) { lnkPackage.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } ImageButton imgPackageAdd = (ImageButton)e.Item.FindControl("imgPackageAdd"); imgPackageAdd.Enabled = Convert.ToBoolean(Convert.ToInt16(lblProductPackageAccess.Text)); if (!imgPackageAdd.Enabled) { imgPackageAdd.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } ImageButton imgInventoryAdjustment = (ImageButton)e.Item.FindControl("imgInventoryAdjustment"); imgInventoryAdjustment.Enabled = Convert.ToBoolean(Convert.ToInt16(lblInvAdjustmentAccess.Text)); if (!imgInventoryAdjustment.Enabled) { imgInventoryAdjustment.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } ImageButton imgProductHistory = (ImageButton)e.Item.FindControl("imgProductHistory"); imgProductHistory.Enabled = Convert.ToBoolean(Convert.ToInt16(lblProductsListReportAccess.Text)); if (!imgProductHistory.Enabled) { imgProductHistory.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } ImageButton imgProductPriceHistory = (ImageButton)e.Item.FindControl("imgProductPriceHistory"); imgProductPriceHistory.Enabled = Convert.ToBoolean(Convert.ToInt16(lblPricesReportAccess.Text)); if (!imgProductPriceHistory.Enabled) { imgProductPriceHistory.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } ImageButton imgChangePrice = (ImageButton)e.Item.FindControl("imgChangePrice"); imgChangePrice.Enabled = Convert.ToBoolean(Convert.ToInt16(lblChangePriceAccess.Text)); if (!imgChangePrice.Enabled) { imgChangePrice.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } ImageButton imgEditNow = (ImageButton)e.Item.FindControl("imgEditNow"); imgEditNow.Enabled = cmdEdit.Visible; if (!imgEditNow.Enabled) { imgEditNow.ImageUrl = Constants.ROOT_DIRECTORY + "/_layouts/images/blank.gif"; } } }
private void Upload() { if ((txtPath.PostedFile != null) && (txtPath.PostedFile.ContentLength > 0)) { string fn = System.IO.Path.GetFileName(txtPath.PostedFile.FileName); string SaveLocation = "/RetailPlus/temp/uploaded_" + fn; txtPath.PostedFile.SaveAs(SaveLocation); XmlTextReader reader = new XmlTextReader(SaveLocation); reader.WhitespaceHandling = WhitespaceHandling.None; Stock clsStock = new Stock(); clsStock.GetConnection(); string strStockTransactionNo = null; long StockID = 0; long ContactID = 0; int UnitID = 0; long ProductGroupID = 0; long ProductSubGroupID = 0; long ProductID = 0; long ProductBaseMatrixID = 0; VariationDetails clsVariationDetails; int VariationID = 0; StockItemDetails clsStockItemDetails = new StockItemDetails(); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == "Stock") { strStockTransactionNo = reader.GetAttribute("TransactionNo"); StockID = clsStock.Details(reader.GetAttribute("TransactionNo")).StockID; if (StockID > 0) { clsStock.CommitAndDispose(); Label1.Text = "<b>This file has already been added to inventory.<br />"; Label1.Text += "Please refer to transaction No: " + strStockTransactionNo + ".</b>"; reader.Close(); return; } Contacts clsContact = new Contacts(clsStock.Connection, clsStock.Transaction); ContactID = clsContact.Details(reader.GetAttribute("ContactCode")).ContactID; if (ContactID == 0) { ContactDetails clsContactDetails = new ContactDetails(); clsContactDetails.ContactCode = reader.GetAttribute("ContactCode"); clsContactDetails.ContactName = reader.GetAttribute("ContactName"); clsContactDetails.ContactGroupID = Convert.ToInt32(reader.GetAttribute("ContactGroupID")); clsContactDetails.ModeOfTerms = (ModeOfTerms)Enum.Parse(typeof(ModeOfTerms), reader.GetAttribute("ModeOfTerms")); clsContactDetails.Terms = Convert.ToInt32(reader.GetAttribute("Terms")); clsContactDetails.Address = reader.GetAttribute("Address"); clsContactDetails.BusinessName = reader.GetAttribute("BusinessName"); clsContactDetails.TelephoneNo = reader.GetAttribute("TelephoneNo"); clsContactDetails.Remarks = reader.GetAttribute("Remarks"); clsContactDetails.Debit = Convert.ToDecimal(reader.GetAttribute("Debit")); clsContactDetails.Credit = Convert.ToDecimal(reader.GetAttribute("Credit")); clsContactDetails.IsCreditAllowed = Convert.ToBoolean(reader.GetAttribute("IsCreditAllowed")); clsContactDetails.CreditLimit = Convert.ToDecimal(reader.GetAttribute("CreditLimit")); ContactID = clsContact.Insert(clsContactDetails); } StockDetails clsStockDetails = new StockDetails(); clsStockDetails.TransactionNo = reader.GetAttribute("TransactionNo"); clsStockDetails.StockTypeID = Convert.ToInt16(Constants.STOCK_TYPE_TRANSFER_FROM_BRANCH_ID); clsStockDetails.StockDate = DateTime.Now; clsStockDetails.SupplierID = ContactID; clsStockDetails.Remarks = reader.GetAttribute("StockRemarks") + Environment.NewLine + "Original Stock Date: " + reader.GetAttribute("StockDate"); StockItemDetails[] itemDetails = new StockItemDetails[0]; clsStockDetails.StockItems = itemDetails; StockID = clsStock.Insert(clsStockDetails); } else if (reader.Name == "Item") { Data.Unit clsUnit = new Data.Unit(clsStock.Connection, clsStock.Transaction); UnitID = clsUnit.Details(reader.GetAttribute("ProductUnitCode")).UnitID; if (UnitID == 0) { UnitDetails clsUnitDetails = new UnitDetails(); clsUnitDetails.UnitCode = reader.GetAttribute("ProductUnitCode"); clsUnitDetails.UnitName = reader.GetAttribute("ProductUnitName"); UnitID = clsUnit.Insert(clsUnitDetails); } ProductGroup clsProductGroup = new ProductGroup(clsStock.Connection, clsStock.Transaction); ProductGroupID = clsProductGroup.Details(reader.GetAttribute("ProductGroupCode")).ProductGroupID; if (ProductGroupID == 0) { Label1.Text += "inserting product group...."; ProductGroupDetails clsProductGroupDetails = new ProductGroupDetails(); clsProductGroupDetails.ProductGroupCode = reader.GetAttribute("ProductGroupCode"); clsProductGroupDetails.ProductGroupName = reader.GetAttribute("ProductGroupName"); clsProductGroupDetails.UnitDetails = new UnitDetails { UnitID = UnitID }; clsProductGroupDetails.Price = Convert.ToDecimal(reader.GetAttribute("Price")); clsProductGroupDetails.PurchasePrice = Convert.ToDecimal(reader.GetAttribute("PurchasePrice")); clsProductGroupDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount")); clsProductGroupDetails.VAT = Convert.ToDecimal(reader.GetAttribute("VAT")); clsProductGroupDetails.EVAT = Convert.ToDecimal(reader.GetAttribute("EVAT")); clsProductGroupDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax")); ProductGroupID = clsProductGroup.Insert(clsProductGroupDetails); } ProductSubGroup clsProductSubGroup = new ProductSubGroup(clsStock.Connection, clsStock.Transaction); ProductSubGroupID = clsProductSubGroup.Details(reader.GetAttribute("ProductSubGroupCode")).ProductSubGroupID; if (ProductSubGroupID == 0) { Label1.Text += "inserting product sub-group...."; ProductSubGroupDetails clsProductSubGroupDetails = new ProductSubGroupDetails(); clsProductSubGroupDetails.ProductGroupID = ProductGroupID; clsProductSubGroupDetails.ProductSubGroupCode = reader.GetAttribute("ProductSubGroupCode"); clsProductSubGroupDetails.ProductSubGroupName = reader.GetAttribute("ProductSubGroupName"); clsProductSubGroupDetails.BaseUnitID = UnitID; clsProductSubGroupDetails.Price = Convert.ToDecimal(reader.GetAttribute("Price")); clsProductSubGroupDetails.PurchasePrice = Convert.ToDecimal(reader.GetAttribute("PurchasePrice")); clsProductSubGroupDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount")); clsProductSubGroupDetails.VAT = Convert.ToDecimal(reader.GetAttribute("VAT")); clsProductSubGroupDetails.EVAT = Convert.ToDecimal(reader.GetAttribute("EVAT")); clsProductSubGroupDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax")); ProductSubGroupID = clsProductSubGroup.Insert(clsProductSubGroupDetails); } Products clsProduct = new Products(clsStock.Connection, clsStock.Transaction); ProductID = clsProduct.Details(reader.GetAttribute("BarCode")).ProductID; if (ProductID == 0) { Label1.Text += "inserting product...."; ProductDetails clsProductDetails = new ProductDetails(); clsProductDetails.ProductCode = reader.GetAttribute("ProductCode"); clsProductDetails.BarCode = reader.GetAttribute("BarCode"); clsProductDetails.ProductDesc = reader.GetAttribute("ProductDesc"); clsProductDetails.ProductGroupID = ProductGroupID; clsProductDetails.ProductSubGroupID = ProductSubGroupID; clsProductDetails.ProductDesc = reader.GetAttribute("ProductDesc"); clsProductDetails.BaseUnitID = UnitID; clsProductDetails.Price = Convert.ToDecimal(reader.GetAttribute("Price")); clsProductDetails.PurchasePrice = Convert.ToDecimal(reader.GetAttribute("PurchasePrice")); clsProductDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount")); clsProductDetails.VAT = Convert.ToDecimal(reader.GetAttribute("VAT")); clsProductDetails.EVAT = Convert.ToDecimal(reader.GetAttribute("EVAT")); clsProductDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax")); clsProductDetails.Quantity = 0; clsProductDetails.MinThreshold = Convert.ToDecimal(reader.GetAttribute("MinThreshold")); clsProductDetails.MaxThreshold = Convert.ToDecimal(reader.GetAttribute("MaxThreshold")); clsProductDetails.SupplierID = Contacts.DEFAULT_SUPPLIER_ID; ProductID = clsProduct.Insert(clsProductDetails); } //ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsStock.Connection, clsStock.Transaction); //ProductBaseMatrixID = clsProductVariationsMatrix.BaseDetails(0, 0, ProductID, reader["ItemBaseVariationDescription"].ToString()).MatrixID; //if (ProductBaseMatrixID == 0) //{ // ProductBaseMatrixDetails clsBaseDetails = new ProductBaseMatrixDetails(); // clsBaseDetails.ProductID = ProductID; // clsBaseDetails.Description = reader.GetAttribute("ItemBaseVariationDescription"); // clsBaseDetails.UnitID = UnitID; // clsBaseDetails.Price = Convert.ToDecimal(reader.GetAttribute("Price")); // clsBaseDetails.PurchasePrice = Convert.ToDecimal(reader.GetAttribute("PurchasePrice")); // clsBaseDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount")); // clsBaseDetails.Quantity = 0; // clsBaseDetails.VAT = Convert.ToDecimal(reader.GetAttribute("VAT")); // clsBaseDetails.EVAT = Convert.ToDecimal(reader.GetAttribute("EVAT")); // clsBaseDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax")); // clsBaseDetails.MinThreshold = Convert.ToDecimal(reader.GetAttribute("MinThreshold")); // clsBaseDetails.MaxThreshold = Convert.ToDecimal(reader.GetAttribute("MaxThreshold")); // ProductBaseMatrixID = clsProductVariationsMatrix.InsertBaseVariation(clsBaseDetails); // clsBaseDetails.MatrixID = ProductBaseMatrixID; //} clsStockItemDetails = new StockItemDetails(); clsStockItemDetails.StockID = StockID; clsStockItemDetails.ProductID = ProductID; clsStockItemDetails.VariationMatrixID = ProductBaseMatrixID; clsStockItemDetails.ProductUnitID = UnitID; clsStockItemDetails.StockTypeID = Convert.ToInt16(Constants.STOCK_TYPE_TRANSFER_FROM_BRANCH_ID); clsStockItemDetails.StockDate = DateTime.Now; clsStockItemDetails.Quantity = Convert.ToDecimal(reader.GetAttribute("ItemQuantity")); clsStockItemDetails.Remarks = reader.GetAttribute("ItemRemarks"); Security.AccessUserDetails clsAccessUserDetails = (Security.AccessUserDetails)Session["AccessUserDetails"]; clsStock.AddItem(Constants.BRANCH_ID_MAIN, strStockTransactionNo, clsAccessUserDetails.Name, clsStockItemDetails, StockDirections.Increment); } else if (reader.Name == "Variation" && reader.GetAttribute("VariationCode") != null) { Variation clsVariation = new Variation(clsStock.Connection, clsStock.Transaction); VariationID = clsVariation.Details(reader.GetAttribute("VariationCode")).VariationID; if (VariationID == 0) { clsVariationDetails = new VariationDetails(); clsVariationDetails.VariationCode = reader.GetAttribute("VariationCode"); clsVariationDetails.VariationType = reader.GetAttribute("VariationType"); VariationID = clsVariation.Insert(clsVariationDetails); } ProductVariationDetails clsProductVariationDetails = new ProductVariationDetails(); clsProductVariationDetails.ProductID = ProductID; clsProductVariationDetails.VariationID = VariationID; ProductVariations clsProductVariation = new ProductVariations(clsStock.Connection, clsStock.Transaction); if (clsProductVariation.isExist(clsProductVariationDetails) == false) { long ProductVariationID = clsProductVariation.Insert(clsProductVariationDetails); } } else if (reader.Name == "VariationMatrix" && reader.GetAttribute("VariationCode") != null) { Variation clsVariation = new Variation(clsStock.Connection, clsStock.Transaction); VariationID = clsVariation.Details(reader.GetAttribute("VariationCode")).VariationID; if (VariationID == 0) { clsVariationDetails = new VariationDetails(); clsVariationDetails.VariationCode = reader.GetAttribute("VariationCode"); clsVariationDetails.VariationType = reader.GetAttribute("VariationType"); VariationID = clsVariation.Insert(clsVariationDetails); } ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsStock.Connection, clsStock.Transaction); if (clsProductVariationsMatrix.isExist(ProductBaseMatrixID, VariationID) == false) { ProductVariationsMatrixDetails clsProductVariationsMatrixDetails = new ProductVariationsMatrixDetails(); clsProductVariationsMatrixDetails.ProductID = ProductID; clsProductVariationsMatrixDetails.MatrixID = ProductBaseMatrixID; clsProductVariationsMatrixDetails.VariationID = VariationID; clsProductVariationsMatrixDetails.Description = reader.GetAttribute("Description"); clsProductVariationsMatrix.SaveVariation(clsProductVariationsMatrixDetails); } } else { Label1.Text = "<b>Reader Name:<b>" + reader.Name + "<br />"; } break; case XmlNodeType.Text: Label1.Text = "<b>" + reader.LocalName + ":<b>" + reader.Value + "<br />"; break; } } reader.Close(); clsStock.CommitAndDispose(); Label1.Text = "<b>Transaction No.: " + strStockTransactionNo + " has been successfully transferred.<br />"; } else { Response.Write("Please select a file to upload."); } }
private static void HandleVariationAndAttributes(HtmlDocument doc, Product product, int imageId) { var variationDiv = doc.DocumentNode.Descendants() .FirstOrDefault(a => a.GetAttributeValue("id", string.Empty).Equals("j-product-info-sku")); var attributeOptionsGroupList = new List <AttributeOptionsGroup>(); if (variationDiv != null) { var dls = variationDiv.Descendants().Where(a => a.Name.Equals("dl")); if (dls.Any()) { product.type = "variable"; } else { product.type = "simple"; } foreach (var dl in dls) { var attributeName = dl.Descendants().First(a => a.Name.Equals("dt")).InnerText; var ul = dl.Descendants().First(a => a.Name.Equals("ul")); var attributeOptionsGroup = new AttributeOptionsGroup(); attributeOptionsGroup.AttributeName = attributeName; foreach (var li in ul.Descendants().Where(a => a.Name.Equals("li"))) { var anchor = li.Descendants().First(a => a.Name.Equals("a")); var anchorTitle = anchor.GetAttributeValue("title", ""); var attributeValue = ""; var attributeImage = ""; if (!string.IsNullOrWhiteSpace(anchorTitle)) { attributeValue = anchorTitle; var img = anchor.Descendants().FirstOrDefault(a => a.Name.Equals("img")); if (img != null) { attributeImage = img.GetAttributeValue("bigpic", ""); } } else { var span = anchor.Descendants().First(a => a.Name.Equals("span")); attributeValue = span.InnerText; } var attributeOptions = new SingleAttributeOptions(); attributeOptions.ImageUrl = attributeImage; attributeOptions.AttributeValue = attributeValue; attributeOptions.Id = imageId; imageId++; attributeOptionsGroup.Options.Add(attributeOptions); } attributeOptionsGroupList.Add(attributeOptionsGroup); } } var productVariations = new List <ProductVariations>(); for (int i = 0; i < 1; i++) { if (attributeOptionsGroupList.Count == 1) { var firstGroup = attributeOptionsGroupList.ElementAt(0); foreach (var firstLevel in firstGroup.Options) { var variation = new ProductVariations(); variation.id = i; variation.regular_price = product.regular_price; variation.sale_price = product.sale_price; variation.price = product.price; if (!string.IsNullOrWhiteSpace(firstLevel.ImageUrl)) { variation.image.Add(new ProductImage { //position = (short)firstLevel.Id, src = firstLevel.ImageUrl, title = firstLevel.AttributeValue, //id = firstLevel.Id }); } variation.attributes.Add(new ProductSpecificAttribute { name = firstGroup.AttributeName, option = firstLevel.AttributeValue, slug = firstGroup.AttributeName }); productVariations.Add(variation); } } else if (attributeOptionsGroupList.Count == 2) { var firstGroup = attributeOptionsGroupList.ElementAt(0); var secondGroup = attributeOptionsGroupList.ElementAt(1); foreach (var firstLevel in firstGroup.Options) { foreach (var secondLevel in secondGroup.Options) { var variation = new ProductVariations(); variation.regular_price = product.regular_price; variation.sale_price = product.sale_price; variation.price = product.price; variation.id = i; if (!string.IsNullOrWhiteSpace(firstLevel.ImageUrl)) { variation.image.Add(new ProductImage { //position = (short)firstLevel.Id, src = firstLevel.ImageUrl, title = firstLevel.AttributeValue, //id = firstLevel.Id }); } if (!string.IsNullOrWhiteSpace(secondLevel.ImageUrl)) { variation.image.Add(new ProductImage { //position = (short)firstLevel.Id, src = secondLevel.ImageUrl, title = secondLevel.AttributeValue, //id = firstLevel.Id }); } variation.attributes.Add(new ProductSpecificAttribute { name = firstGroup.AttributeName, option = firstLevel.AttributeValue, slug = firstGroup.AttributeName }); variation.attributes.Add(new ProductSpecificAttribute { name = secondGroup.AttributeName, option = secondLevel.AttributeValue, slug = secondGroup.AttributeName }); productVariations.Add(variation); } } } } product.variations = productVariations; product.attributes = new List <ProductAttribute>(); var attributeIndex = 0; foreach (var group in attributeOptionsGroupList) { var attribute = new ProductAttribute(); attribute.name = @group.AttributeName; attribute.position = attributeIndex; attribute.visible = true; attribute.variation = true; attribute.options = @group.Options.Select(a => a.AttributeValue).ToList(); attributeIndex++; product.attributes.Add(attribute); } }
/// <summary> /// Constructs the ProductVariation model /// </summary> /// <param name="productVariations"></param> public ProductVariation(ProductVariations productVariations) { this.ProductVariations = productVariations; }