public static Collection<StockMasterDetailModel> GetDetails(string json, int storeId) { Collection<StockMasterDetailModel> details = new Collection<StockMasterDetailModel>(); var jss = new JavaScriptSerializer(); dynamic result = jss.Deserialize<dynamic>(json); foreach (var item in result) { StockMasterDetailModel detail = new StockMasterDetailModel(); detail.ItemCode = item[0]; detail.Quantity = Conversion.TryCastInteger(item[2]); detail.UnitName = item[3]; detail.Price = Conversion.TryCastDecimal(item[4]); detail.Discount = Conversion.TryCastDecimal(item[6]); detail.TaxRate = Conversion.TryCastDecimal(item[8]); detail.Tax = Conversion.TryCastDecimal(item[9]); detail.StoreId = storeId; details.Add(detail); } return details; }
/// <summary> /// This function returns a new instance of ControlCollection class. /// The control collection is processed on the page which contains this UserControl /// for transaction posting. /// </summary> /// <returns></returns> private ControlData GetControls() { ControlData collection = new ControlData(); collection.Date = Conversion.TryCastDate(this.DateTextBox.Text); collection.StoreId = Conversion.TryCastInteger(GetDropDownValue(this.StoreDropDownList)); collection.TransactionType = this.TransactionTypeRadioButtonList.SelectedItem.Value; collection.PartyCode = this.PartyCodeTextBox.Text; collection.PriceTypeId = Conversion.TryCastInteger(GetDropDownValue(this.PriceTypeDropDownList)); collection.ReferenceNumber = this.ReferenceNumberTextBox.Text; collection.RunningTotal = Conversion.TryCastDecimal(this.RunningTotalTextBox.Text); collection.TaxTotal = Conversion.TryCastDecimal(this.TaxTotalTextBox.Text); collection.GrandTotal = Conversion.TryCastDecimal(this.GrandTotalTextBox.Text); collection.ShippingAddressCode = this.ShippingAddressCodeHidden.Value; collection.ShippingCompanyId = Conversion.TryCastInteger(GetDropDownValue(this.ShippingCompanyDropDownList)); collection.ShippingCharge = Conversion.TryCastDecimal(this.ShippingChargeTextBox.Text); collection.CashRepositoryId = Conversion.TryCastInteger(GetDropDownValue(this.CashRepositoryDropDownList)); collection.CostCenterId = Conversion.TryCastInteger(GetDropDownValue(this.CostCenterDropDownList)); collection.AgentId = Conversion.TryCastInteger(GetDropDownValue(this.SalespersonDropDownList)); collection.StatementReference = this.StatementReferenceTextBox.Text; if (this.ProductGridView != null) { if (this.ProductGridView.Rows.Count > 0) { for (int i = 1; i < ProductGridView.Rows.Count; i++) { StockMasterDetailModel detail = new StockMasterDetailModel(); detail.ItemCode = ProductGridView.Rows[i].Cells[0].Text; detail.Quantity = MixERP.Net.Common.Conversion.TryCastInteger(ProductGridView.Rows[i].Cells[2].Text); detail.UnitName = ProductGridView.Rows[i].Cells[3].Text; detail.Price = MixERP.Net.Common.Conversion.TryCastDecimal(ProductGridView.Rows[i].Cells[4].Text); detail.Discount = MixERP.Net.Common.Conversion.TryCastDecimal(ProductGridView.Rows[i].Cells[6].Text); detail.TaxRate = MixERP.Net.Common.Conversion.TryCastDecimal(ProductGridView.Rows[i].Cells[8].Text); detail.Tax = MixERP.Net.Common.Conversion.TryCastDecimal(ProductGridView.Rows[i].Cells[9].Text); detail.StoreId = MixERP.Net.Common.Conversion.TryCastInteger(StoreDropDownList.SelectedItem.Value); collection.AddDetail(detail); } } } return collection; }
public void AddDetail(StockMasterDetailModel detail) { details.Add(detail); }