private bool SaveRecord() { ProductGroupVariationsMatrixDetails clsDetails; ProductGroupVariationsMatrix clsProductGroupVariationsMatrix = new ProductGroupVariationsMatrix(); string stringVariationDesc = null; foreach (DataListItem item in lstItem.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList"); TextBox txtDescription = (TextBox)item.FindControl("txtDescription"); clsDetails = new ProductGroupVariationsMatrixDetails(); clsDetails.MatrixID = Convert.ToInt32(lblMatrixID.Text); clsDetails.GroupID = Convert.ToInt32(lblGroupID.Text); clsDetails.VariationID = Convert.ToInt32(chkList.Value); clsDetails.Description = txtDescription.Text; if (clsProductGroupVariationsMatrix.IsVariationExists(clsDetails.MatrixID, clsDetails.VariationID) == false) { clsProductGroupVariationsMatrix.InsertVariation(clsDetails); } else { clsProductGroupVariationsMatrix.UpdateVariation(clsDetails); } //Label lblVariationType = (Label) item.FindControl("lblVariationType"); //stringVariationDesc += lblVariationType.Text + ":" + txtDescription.Text + "; "; stringVariationDesc += txtDescription.Text + "; "; } //update the base variation matrix ProductGroupBaseVariationsMatrixDetails clsBaseDetails = new ProductGroupBaseVariationsMatrixDetails(); clsBaseDetails.MatrixID = Convert.ToInt32(lblMatrixID.Text); clsBaseDetails.GroupID = Convert.ToInt32(lblGroupID.Text); clsBaseDetails.Description = stringVariationDesc; clsBaseDetails.UnitID = Convert.ToInt32(cboUnit.SelectedItem.Value); clsBaseDetails.Price = Convert.ToDecimal(txtProductPrice.Text); clsBaseDetails.PurchasePrice = Convert.ToDecimal(txtPurchasePrice.Text); clsBaseDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(chkIncludeInSubtotalDiscount.Checked); clsBaseDetails.VAT = Convert.ToDecimal(txtVAT.Text); clsBaseDetails.EVAT = Convert.ToDecimal(txtEVAT.Text); clsBaseDetails.LocalTax = Convert.ToDecimal(txtLocalTax.Text); clsProductGroupVariationsMatrix.UpdateBaseVariation(clsBaseDetails); clsProductGroupVariationsMatrix.CommitAndDispose(); return(true); }
private void LoadRecord() { ProductGroupVariationsMatrix clsProductGroupVariationsMatrix = new ProductGroupVariationsMatrix(); ProductGroupBaseVariationsMatrixDetails clsBaseDetails = clsProductGroupVariationsMatrix.BaseDetails(Convert.ToInt32(lblMatrixID.Text), Convert.ToInt32(lblGroupID.Text)); clsProductGroupVariationsMatrix.CommitAndDispose(); cboUnit.SelectedIndex = cboUnit.Items.IndexOf(cboUnit.Items.FindByValue(clsBaseDetails.UnitID.ToString())); txtProductPrice.Text = clsBaseDetails.Price.ToString("#,##0.#0"); txtPurchasePrice.Text = clsBaseDetails.PurchasePrice.ToString("#,##0.#0"); decimal decMargin = clsBaseDetails.Price - clsBaseDetails.PurchasePrice; try { decMargin = decMargin / clsBaseDetails.PurchasePrice; } catch { decMargin = 1; } decMargin = decMargin * 100; txtMargin.Text = decMargin.ToString("#,##0.##0"); chkIncludeInSubtotalDiscount.Checked = clsBaseDetails.IncludeInSubtotalDiscount; txtVAT.Text = clsBaseDetails.VAT.ToString("#,##0.#0"); txtEVAT.Text = clsBaseDetails.EVAT.ToString("#,##0.#0"); txtLocalTax.Text = clsBaseDetails.LocalTax.ToString("#,##0.#0"); }