private void Import() { if (txtPath.HasFile) { string fn = System.IO.Path.GetFileName(txtPath.PostedFile.FileName); if (fn.Contains("_" + Constants.PURCHASE_ORDER_CODE) == false) { string stScript = "<Script>"; stScript += "window.alert('Please select a VALID Purchase Order file to upload.')"; stScript += "</Script>"; Response.Write(stScript); return; } string SaveLocation = "/RetailPlus/temp/uploaded_" + fn; txtPath.PostedFile.SaveAs(SaveLocation); XmlTextReader xmlReader = new XmlTextReader(SaveLocation); xmlReader.WhitespaceHandling = WhitespaceHandling.None; PO clsPO = new PO(); clsPO.GetConnection(); PODetails clsPODetails = new PODetails(); POItem clsPOItem = new POItem(clsPO.Connection, clsPO.Transaction); POItemDetails clsPOItemDetails; Contacts clsContact = new Contacts(clsPO.Connection, clsPO.Transaction); ContactDetails clsContactDetails; ContactGroups clsContactGroup = new ContactGroups(clsPO.Connection, clsPO.Transaction); ContactGroupDetails clsContactGroupDetails; Data.Unit clsUnit = new Data.Unit(clsPO.Connection, clsPO.Transaction); UnitDetails clsUnitDetails; ProductGroup clsProductGroup = new Data.ProductGroup(clsPO.Connection, clsPO.Transaction); ProductGroupDetails clsProductGroupDetails; ProductSubGroup clsProductSubGroup = new Data.ProductSubGroup(clsPO.Connection, clsPO.Transaction); ProductSubGroupDetails clsProductSubGroupDetails; Products clsProduct = new Products(clsPO.Connection, clsPO.Transaction); ProductDetails clsProductDetails; ProductVariations clsProductVariation = new ProductVariations(clsPO.Connection, clsPO.Transaction); ProductVariationDetails clsProductVariationDetails; Branch clsBranch = new Branch(clsPO.Connection, clsPO.Transaction); BranchDetails clsBranchDetails; long lngProductID = 0; long lngProductCtr = 0; while (xmlReader.Read()) { switch (xmlReader.NodeType) { case XmlNodeType.Element: if (xmlReader.Name == "PODetails") { clsPODetails.PONo = lnkPONo.Text; clsPODetails.PODate = DateTime.Parse(lblPODate.Text); clsPODetails.SupplierCode = xmlReader.GetAttribute("SupplierCode").ToString(); clsPODetails.SupplierContact = xmlReader.GetAttribute("SupplierContact").ToString(); clsPODetails.SupplierAddress = xmlReader.GetAttribute("SupplierAddress").ToString(); clsPODetails.SupplierTelephoneNo = xmlReader.GetAttribute("SupplierTelephoneNo").ToString(); clsPODetails.SupplierModeOfTerms = int.Parse(xmlReader.GetAttribute("SupplierModeOfTerms").ToString()); clsPODetails.SupplierTerms = int.Parse(xmlReader.GetAttribute("SupplierTerms").ToString()); clsPODetails.SupplierID = clsContact.Details(xmlReader.GetAttribute("SupplierCode").ToString()).ContactID; if (clsPODetails.SupplierID == 0) { clsContactDetails = new ContactDetails(); clsContactDetails.ContactCode = clsPODetails.SupplierCode; clsContactDetails.ContactName = xmlReader.GetAttribute("SupplierName").ToString(); clsContactDetails.BusinessName = clsPODetails.SupplierContact; clsContactDetails.Address = clsPODetails.SupplierAddress; clsContactDetails.TelephoneNo = clsPODetails.SupplierTelephoneNo; clsContactDetails.ModeOfTerms = (ModeOfTerms)Enum.Parse(typeof(ModeOfTerms), clsPODetails.SupplierModeOfTerms.ToString()); clsContactDetails.Terms = clsPODetails.SupplierTerms; clsContactDetails.Remarks = "Added in from Imported PO #"; clsContactDetails.ContactGroupID = int.Parse(Contacts.DEFAULT_SUPPLIER_ID.ToString("d")); clsContactDetails.DateCreated = DateTime.Now; clsPODetails.SupplierID = clsContact.Insert(clsContactDetails); } clsPODetails.RequiredDeliveryDate = DateTime.Parse(xmlReader.GetAttribute("RequiredDeliveryDate").ToString()); clsPODetails.BranchID = clsBranch.Details(xmlReader.GetAttribute("BranchCode")).BranchID; if (clsPODetails.BranchID == 0) { clsBranchDetails = new BranchDetails(); clsBranchDetails.BranchCode = xmlReader.GetAttribute("BranchCode"); clsBranchDetails.BranchName = xmlReader.GetAttribute("BranchName"); clsBranchDetails.Address = xmlReader.GetAttribute("BranchAddress"); clsBranchDetails.DBIP = xmlReader.GetAttribute("BranchDBIP"); clsBranchDetails.DBPort = xmlReader.GetAttribute("BranchDBPort"); clsBranchDetails.Remarks = xmlReader.GetAttribute("BranchRemarks"); clsPODetails.BranchID = clsBranch.Insert(clsBranchDetails); } clsPODetails.PurchaserID = long.Parse(xmlReader.GetAttribute("PurchaserID")); clsPODetails.PurchaserName = xmlReader.GetAttribute("PurchaserName"); clsPODetails.SubTotal = decimal.Parse(xmlReader.GetAttribute("SubTotal")); clsPODetails.Discount = decimal.Parse(xmlReader.GetAttribute("Discount")); clsPODetails.DiscountApplied = decimal.Parse(xmlReader.GetAttribute("DiscountApplied")); clsPODetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), xmlReader.GetAttribute("DiscountType")); clsPODetails.VAT = decimal.Parse(xmlReader.GetAttribute("VAT")); clsPODetails.VatableAmount = decimal.Parse(xmlReader.GetAttribute("VatableAmount")); clsPODetails.EVAT = decimal.Parse(xmlReader.GetAttribute("EVAT")); clsPODetails.EVatableAmount = decimal.Parse(xmlReader.GetAttribute("EVatableAmount")); clsPODetails.LocalTax = decimal.Parse(xmlReader.GetAttribute("LocalTax")); clsPODetails.Freight = decimal.Parse(xmlReader.GetAttribute("Freight")); clsPODetails.Deposit = decimal.Parse(xmlReader.GetAttribute("Deposit")); clsPODetails.UnpaidAmount = decimal.Parse(xmlReader.GetAttribute("UnpaidAmount")); clsPODetails.PaidAmount = decimal.Parse(xmlReader.GetAttribute("PaidAmount")); clsPODetails.TotalItemDiscount = decimal.Parse(xmlReader.GetAttribute("TotalItemDiscount")); clsPODetails.Status = (POStatus)Enum.Parse(typeof(POStatus), xmlReader.GetAttribute("Status")); clsPODetails.Remarks = xmlReader.GetAttribute("Remarks"); clsPODetails.SupplierDRNo = xmlReader.GetAttribute("SupplierDRNo"); clsPODetails.DeliveryDate = DateTime.Parse(xmlReader.GetAttribute("DeliveryDate")); clsPODetails.CancelledDate = DateTime.Parse(xmlReader.GetAttribute("CancelledDate")); clsPODetails.Remarks = xmlReader.GetAttribute("Remarks"); clsPODetails.CancelledRemarks = xmlReader.GetAttribute("CancelledRemarks"); clsPODetails.CancelledByID = long.Parse(xmlReader.GetAttribute("CancelledByID")); clsPO.Update(clsPODetails); } else if (xmlReader.Name == "POItem") { clsPOItemDetails = new POItemDetails(); clsPOItemDetails.POID = long.Parse(lblPOID.Text); clsPOItemDetails.ProductCode = xmlReader.GetAttribute("ProductCode"); clsPOItemDetails.BarCode = xmlReader.GetAttribute("BarCode"); clsPOItemDetails.Description = xmlReader.GetAttribute("ProductDesc"); clsPOItemDetails.ProductSubGroup = xmlReader.GetAttribute("ItemProductSubGroup"); clsPOItemDetails.ProductGroup = xmlReader.GetAttribute("ItemProductGroup"); clsPOItemDetails.ProductUnitID = Convert.ToInt32(xmlReader.GetAttribute("ItemProductUnitID")); clsPOItemDetails.ProductUnitCode = xmlReader.GetAttribute("ItemProductUnitCode"); clsPOItemDetails.Quantity = Convert.ToDecimal(xmlReader.GetAttribute("ItemQuantity")); clsPOItemDetails.UnitCost = Convert.ToDecimal(xmlReader.GetAttribute("ItemUnitCost")); clsPOItemDetails.Discount = Convert.ToDecimal(xmlReader.GetAttribute("ItemDiscount")); clsPOItemDetails.DiscountApplied = Convert.ToDecimal(xmlReader.GetAttribute("ItemDiscountApplied")); clsPOItemDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), xmlReader.GetAttribute("ItemDiscountType")); clsPOItemDetails.Amount = Convert.ToDecimal(xmlReader.GetAttribute("ItemAmount")); clsPOItemDetails.IsVatable = Convert.ToBoolean(Convert.ToInt16(xmlReader.GetAttribute("ItemIsVatable"))); clsPOItemDetails.VatableAmount = Convert.ToDecimal(xmlReader.GetAttribute("ItemVatableAmount")); clsPOItemDetails.EVatableAmount = Convert.ToDecimal(xmlReader.GetAttribute("ItemEVatableAmount")); clsPOItemDetails.LocalTax = Convert.ToDecimal(xmlReader.GetAttribute("ItemLocalTax")); clsPOItemDetails.VAT = Convert.ToDecimal(xmlReader.GetAttribute("ItemVAT")); clsPOItemDetails.EVAT = Convert.ToDecimal(xmlReader.GetAttribute("ItemEVAT")); clsPOItemDetails.LocalTax = Convert.ToDecimal(xmlReader.GetAttribute("ItemLocalTax")); clsPOItemDetails.isVATInclusive = Convert.ToBoolean(Convert.ToInt16(xmlReader.GetAttribute("ItemisVATInclusive"))); clsPOItemDetails.IsVatable = Convert.ToBoolean(Convert.ToInt16(xmlReader.GetAttribute("ItemIsVatable"))); clsPOItemDetails.POItemStatus = (POItemStatus)Enum.Parse(typeof(POItemStatus), xmlReader.GetAttribute("ItemPOItemStatus")); clsPOItemDetails.VariationMatrixID = Convert.ToInt64(xmlReader.GetAttribute("ItemVariationMatrixID")); clsPOItemDetails.MatrixDescription = xmlReader.GetAttribute("ItemBaseVariationDescription"); clsPOItemDetails.ProductGroup = xmlReader.GetAttribute("ProductGroup"); clsPOItemDetails.ProductSubGroup = xmlReader.GetAttribute("ProductSubGroup"); clsPOItemDetails.Remarks = xmlReader.GetAttribute("ItemRemarks"); clsPOItemDetails.SellingPrice = Convert.ToDecimal(xmlReader.GetAttribute("ItemSellingPrice")); clsPOItemDetails.SellingVAT = Convert.ToDecimal(xmlReader.GetAttribute("ItemSellingVAT")); clsPOItemDetails.SellingEVAT = Convert.ToDecimal(xmlReader.GetAttribute("ItemSellingEVAT")); clsPOItemDetails.SellingLocalTax = Convert.ToDecimal(xmlReader.GetAttribute("ItemSellingLocalTax")); clsPOItemDetails.OldSellingPrice = Convert.ToDecimal(xmlReader.GetAttribute("ItemOldSellingPrice")); clsPOItemDetails.ProductID = clsProduct.Details(clsPOItemDetails.BarCode).ProductID; lngProductID = clsPOItemDetails.ProductID; if (clsPOItemDetails.ProductID == 0) { clsPOItemDetails.ProductID = clsProduct.Details(clsPOItemDetails.ProductCode).ProductID; if (clsPOItemDetails.ProductID == 0) { //insert new product clsProductDetails = new ProductDetails(); clsProductDetails.BarCode = clsPOItemDetails.BarCode; clsProductDetails.ProductCode = clsPOItemDetails.ProductCode; clsProductDetails.ProductDesc = clsPOItemDetails.Description; clsProductDetails.ProductGroupCode = xmlReader.GetAttribute("ProductGroupCode"); clsProductDetails.ProductGroupName = xmlReader.GetAttribute("ProductGroupName"); clsProductDetails.ProductSubGroupCode = xmlReader.GetAttribute("ProductSubGroupCode"); clsProductDetails.ProductSubGroupName = xmlReader.GetAttribute("ProductSubGroupName"); clsProductDetails.BaseUnitCode = xmlReader.GetAttribute("BaseUnitCode"); clsProductDetails.BaseUnitName = xmlReader.GetAttribute("BaseUnitName"); clsProductDetails.DateCreated = DateTime.Now; clsProductDetails.Price = Convert.ToDecimal(xmlReader.GetAttribute("Price")); clsProductDetails.PurchasePrice = Convert.ToDecimal(xmlReader.GetAttribute("PurchasePrice")); clsProductDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(xmlReader.GetAttribute("IncludeInSubtotalDiscount")); clsProductDetails.VAT = Convert.ToDecimal(xmlReader.GetAttribute("VAT")); clsProductDetails.EVAT = Convert.ToDecimal(xmlReader.GetAttribute("EVAT")); clsProductDetails.LocalTax = Convert.ToDecimal(xmlReader.GetAttribute("LocalTax")); clsProductDetails.Quantity = 0; clsProductDetails.MinThreshold = Convert.ToDecimal(xmlReader.GetAttribute("MinThreshold")); clsProductDetails.MaxThreshold = Convert.ToDecimal(xmlReader.GetAttribute("MaxThreshold")); clsProductDetails.ChartOfAccountIDPurchase = int.Parse(xmlReader.GetAttribute("ChartOfAccountIDPurchase")); clsProductDetails.ChartOfAccountIDSold = int.Parse(xmlReader.GetAttribute("ChartOfAccountIDSold")); clsProductDetails.ChartOfAccountIDInventory = int.Parse(xmlReader.GetAttribute("ChartOfAccountIDInventory")); clsProductDetails.ChartOfAccountIDTaxPurchase = int.Parse(xmlReader.GetAttribute("ChartOfAccountIDTaxPurchase")); clsProductDetails.ChartOfAccountIDTaxSold = int.Parse(xmlReader.GetAttribute("ChartOfAccountIDTaxSold")); clsProductDetails.IsItemSold = Convert.ToBoolean(xmlReader.GetAttribute("IsItemSold")); clsProductDetails.WillPrintProductComposition = Convert.ToBoolean(xmlReader.GetAttribute("WillPrintProductComposition")); clsProductDetails.UpdatedBy = long.Parse(xmlReader.GetAttribute("UpdatedBy")); clsProductDetails.UpdatedOn = Convert.ToDateTime(xmlReader.GetAttribute("UpdatedOn")); clsProductDetails.PercentageCommision = decimal.Parse(xmlReader.GetAttribute("PercentageCommision")); clsProductDetails.QuantityIN = clsProductDetails.Quantity; clsProductDetails.QuantityOUT = 0; clsProductDetails.SupplierCode = clsPODetails.SupplierCode; clsProductDetails.SupplierID = clsContact.Details(clsProductDetails.SupplierCode).ContactID; if (clsProductDetails.SupplierID == 0) { clsContactDetails = new ContactDetails(); clsContactDetails.ContactGroupID = clsContactGroup.Details(int.Parse(ContactGroupCategory.SUPPLIER.ToString("d"))).ContactGroupID; if (clsContactDetails.ContactGroupID == 0) { clsContactGroupDetails = new ContactGroupDetails(); clsContactGroupDetails.ContactGroupCode = xmlReader.GetAttribute("SUP"); clsContactGroupDetails.ContactGroupName = xmlReader.GetAttribute("Default Supplier Group"); clsContactGroupDetails.ContactGroupCategory = ContactGroupCategory.SUPPLIER; clsContactDetails.ContactGroupID = clsContactGroup.Insert(clsContactGroupDetails); } clsContactDetails.ContactCode = clsPODetails.SupplierCode; clsContactDetails.ContactName = clsPODetails.SupplierContact; clsContactDetails.ModeOfTerms = (ModeOfTerms)Enum.Parse(typeof(ModeOfTerms), clsPODetails.SupplierModeOfTerms.ToString()); clsContactDetails.Terms = clsPODetails.SupplierTerms; clsContactDetails.Address = clsPODetails.SupplierAddress; clsContactDetails.BusinessName = clsPODetails.SupplierContact; clsContactDetails.TelephoneNo = clsPODetails.SupplierTelephoneNo; clsContactDetails.Remarks = "Added in XML import"; clsContactDetails.Debit = 0; clsContactDetails.Credit = 0; clsContactDetails.IsCreditAllowed = false; clsContactDetails.CreditLimit = 0; clsProductDetails.SupplierID = clsContact.Insert(clsContactDetails); } clsProductDetails.BaseUnitID = clsUnit.Details(clsProductDetails.BaseUnitCode).UnitID; if (clsProductDetails.BaseUnitID == 0) { clsUnitDetails = new UnitDetails(); clsUnitDetails.UnitCode = clsProductDetails.BaseUnitCode; clsUnitDetails.UnitName = clsProductDetails.BaseUnitName; clsProductDetails.BaseUnitID = clsUnit.Insert(clsUnitDetails); } clsProductDetails.ProductGroupID = clsProductGroup.Details(clsProductDetails.ProductGroupCode).ProductGroupID; if (clsProductDetails.ProductGroupID == 0) { clsProductGroupDetails = new ProductGroupDetails(); clsProductGroupDetails.ProductGroupCode = clsProductDetails.ProductGroupCode; clsProductGroupDetails.ProductGroupName = clsProductDetails.ProductGroupName; clsProductGroupDetails.UnitDetails = new UnitDetails { UnitID = clsProductDetails.BaseUnitID }; clsProductGroupDetails.Price = clsProductDetails.Price; clsProductGroupDetails.PurchasePrice = clsProductDetails.PurchasePrice; clsProductGroupDetails.IncludeInSubtotalDiscount = clsProductDetails.IncludeInSubtotalDiscount; clsProductGroupDetails.VAT = clsProductDetails.VAT; clsProductGroupDetails.EVAT = clsProductDetails.EVAT; clsProductGroupDetails.LocalTax = clsProductDetails.LocalTax; clsProductDetails.ProductGroupID = clsProductGroup.Insert(clsProductGroupDetails); } clsProductDetails.ProductSubGroupID = clsProductSubGroup.Details(clsProductDetails.ProductSubGroupCode).ProductSubGroupID; if (clsProductDetails.ProductSubGroupID == 0) { clsProductSubGroupDetails = new ProductSubGroupDetails(); clsProductSubGroupDetails.ProductGroupID = clsProductDetails.ProductGroupID; clsProductSubGroupDetails.ProductSubGroupCode = clsProductDetails.ProductSubGroupCode; clsProductSubGroupDetails.ProductSubGroupName = clsProductDetails.ProductSubGroupName; clsProductSubGroupDetails.BaseUnitID = clsProductDetails.BaseUnitID; clsProductSubGroupDetails.Price = clsProductDetails.Price; clsProductSubGroupDetails.PurchasePrice = clsProductDetails.PurchasePrice; clsProductSubGroupDetails.IncludeInSubtotalDiscount = clsProductDetails.IncludeInSubtotalDiscount; clsProductSubGroupDetails.VAT = clsProductDetails.VAT; clsProductSubGroupDetails.EVAT = clsProductDetails.EVAT; clsProductSubGroupDetails.LocalTax = clsProductDetails.LocalTax; clsProductDetails.ProductSubGroupID = clsProductSubGroup.Insert(clsProductSubGroupDetails); } clsPOItemDetails.ProductID = clsProduct.Insert(clsProductDetails); } else { //product code already exist but not the same barcode clsProduct.UpdateBarcode(clsPOItemDetails.ProductID, clsPOItemDetails.BarCode); } lngProductID = clsPOItemDetails.ProductID; } clsPOItem.Insert(clsPOItemDetails); clsPODetails = new PODetails(); clsPODetails.POID = clsPOItemDetails.POID; clsPODetails.DiscountApplied = Convert.ToDecimal(txtPODiscountApplied.Text); clsPODetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODiscountType.SelectedItem.Value); clsPODetails.Discount2Applied = Convert.ToDecimal(txtPODiscount2Applied.Text); clsPODetails.Discount2Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODiscount2Type.SelectedItem.Value); clsPODetails.Discount3Applied = Convert.ToDecimal(txtPODiscount2Applied.Text); clsPODetails.Discount3Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODiscount3Type.SelectedItem.Value); clsPO = new PO(clsPOItem.Connection, clsPOItem.Transaction); clsPO.UpdateDiscount(clsPOItemDetails.POID, clsPODetails.DiscountApplied, clsPODetails.DiscountType, clsPODetails.Discount2Applied, clsPODetails.Discount2Type, clsPODetails.Discount3Applied, clsPODetails.Discount3Type); clsPODetails = clsPO.Details(clsPOItemDetails.POID); UpdateFooter(clsPODetails); lngProductCtr++; } else if (xmlReader.Name == "Variation") { if (lngProductID != 0) { clsProductVariationDetails = new ProductVariationDetails(); clsProductVariationDetails.VariationID = clsProductVariation.Details(lngProductID, xmlReader.GetAttribute("VariationCode")).VariationID; if (clsProductVariationDetails.VariationID == 0) { clsProductVariationDetails.ProductID = lngProductID; clsProductVariationDetails.VariationCode = xmlReader.GetAttribute("VariationCode"); clsProductVariationDetails.VariationType = xmlReader.GetAttribute("VariationType"); clsProductVariation.Insert(clsProductVariationDetails); } } } else { //lblError.Text += "<b>" + xmlReader.Name + ":</b>" + xmlReader.Value + "<br />"; } break; case XmlNodeType.Text: //lblError.Text += "<b>" + xmlReader.LocalName + ":</b>" + xmlReader.Value + "<br />"; break; } } xmlReader.Close(); clsPO.CommitAndDispose(); LoadRecord(); LoadItems(); } else { string stScript = "<Script>"; stScript += "window.alert('Please select Purchase Order file to upload.')"; stScript += "</Script>"; Response.Write(stScript); } }
private void SaveRecord() { POItemDetails clsDetails = new POItemDetails(); Products clsProducts = new Products(); ProductDetails clsProductDetails = clsProducts.Details1(Constants.BRANCH_ID_MAIN, Convert.ToInt64(cboProductCode.SelectedItem.Value)); Terminal clsTerminal = new Terminal(clsProducts.Connection, clsProducts.Transaction); TerminalDetails clsTerminalDetails = clsTerminal.Details(Int32.Parse(Session["BranchID"].ToString()), Session["TerminalNo"].ToString()); clsProducts.CommitAndDispose(); clsDetails.POID = Convert.ToInt64(lblPOID.Text); clsDetails.ProductID = Convert.ToInt64(cboProductCode.SelectedItem.Value); clsDetails.ProductCode = clsProductDetails.ProductCode; clsDetails.BarCode = clsProductDetails.BarCode; clsDetails.Description = clsProductDetails.ProductDesc; clsDetails.ProductUnitID = Convert.ToInt32(cboProductUnit.SelectedItem.Value); clsDetails.ProductUnitCode = cboProductUnit.SelectedItem.Text; clsDetails.Quantity = Convert.ToDecimal(txtQuantity.Text); clsDetails.UnitCost = Convert.ToDecimal(txtPrice.Text); clsDetails.Discount = getItemTotalDiscount(); clsDetails.DiscountApplied = Convert.ToDecimal(txtDiscount.Text); if (clsDetails.DiscountApplied == 0) { clsDetails.DiscountType = DiscountTypes.NotApplicable; } else { if (chkInPercent.Checked == true) clsDetails.DiscountType = DiscountTypes.Percentage; else clsDetails.DiscountType = DiscountTypes.FixedValue; } clsDetails.IsVatable = chkIsTaxable.Checked; clsDetails.Amount = ComputeItemAmount(); if (clsDetails.IsVatable) { clsDetails.VatableAmount = clsDetails.Amount; clsDetails.EVatableAmount = clsDetails.Amount; clsDetails.LocalTax = clsDetails.Amount; if (clsTerminalDetails.IsVATInclusive == false) { if (clsDetails.VatableAmount < clsDetails.Discount) clsDetails.VatableAmount = 0; if (clsDetails.EVatableAmount < clsDetails.Discount) clsDetails.EVatableAmount = 0; if (clsDetails.LocalTax < clsDetails.Discount) clsDetails.LocalTax = 0; } else { if (clsDetails.VatableAmount >= clsDetails.Discount) clsDetails.VatableAmount = (clsDetails.VatableAmount) / (1 + (clsTerminalDetails.VAT / 100)); else clsDetails.VatableAmount = 0; if (clsDetails.EVatableAmount >= clsDetails.Discount) clsDetails.EVatableAmount = (clsDetails.EVatableAmount) / (1 + (clsTerminalDetails.VAT / 100)); else clsDetails.EVatableAmount = 0; if (clsDetails.LocalTax >= clsDetails.Discount) clsDetails.LocalTax = (clsDetails.LocalTax) / (1 + (clsTerminalDetails.LocalTax / 100)); else clsDetails.LocalTax = 0; } clsDetails.VAT = clsDetails.VatableAmount * (clsTerminalDetails.VAT / 100); clsDetails.EVAT = clsDetails.EVatableAmount * (clsTerminalDetails.EVAT / 100); clsDetails.LocalTax = clsDetails.LocalTax * (clsTerminalDetails.LocalTax / 100); //if (!clsTerminalDetails.IsVATInclusive) clsDetails.Amount += (clsDetails.VAT + clsDetails.LocalTax); //if (!clsTerminalDetails.EnableEVAT) clsDetails.Amount += clsDetails.EVAT; } else { clsDetails.VAT = 0; clsDetails.VatableAmount = 0; clsDetails.EVAT = 0; clsDetails.EVatableAmount = 0; clsDetails.LocalTax = 0; } clsDetails.isVATInclusive = clsTerminalDetails.IsVATInclusive; clsDetails.VariationMatrixID = Convert.ToInt64(cboVariation.SelectedItem.Value); if (clsDetails.VariationMatrixID != 0) clsDetails.MatrixDescription = cboVariation.SelectedItem.Text; clsDetails.ProductGroup = clsProductDetails.ProductGroupCode; clsDetails.ProductSubGroup = clsProductDetails.ProductSubGroupCode; clsDetails.Remarks = txtRemarks.Text; // Added jan 1, 2010 4:20PM : for selling information clsDetails.SellingPrice = decimal.Parse(txtSellingPrice.Text); clsDetails.SellingVAT = decimal.Parse(txtVAT.Text); clsDetails.SellingEVAT = decimal.Parse(txtEVAT.Text); clsDetails.SellingLocalTax = decimal.Parse(txtLocalTax.Text); clsDetails.OldSellingPrice = decimal.Parse(txtOldSellingPrice.Text); // Aug 9, 2011 : Lemu // For Required Inventory Days clsDetails.RID = long.Parse(txtRID.Text); POItem clsPOItem = new POItem(); if (lblPOItemID.Text != "0") { clsDetails.POItemID = Convert.ToInt64(lblPOItemID.Text); clsPOItem.Update(clsDetails); } else clsPOItem.Insert(clsDetails); PODetails clsPODetails = new PODetails(); clsPODetails.POID = clsDetails.POID; clsPODetails.DiscountApplied = Convert.ToDecimal(txtPODiscountApplied.Text); clsPODetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODiscountType.SelectedItem.Value); clsPODetails.Discount2Applied = Convert.ToDecimal(txtPODiscount2Applied.Text); clsPODetails.Discount2Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODiscount2Type.SelectedItem.Value); clsPODetails.Discount3Applied = Convert.ToDecimal(txtPODiscount3Applied.Text); clsPODetails.Discount3Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODiscount3Type.SelectedItem.Value); PO clsPO = new PO(clsPOItem.Connection, clsPOItem.Transaction); clsPO.UpdateDiscount(clsDetails.POID, clsPODetails.DiscountApplied, clsPODetails.DiscountType, clsPODetails.Discount2Applied, clsPODetails.Discount2Type, clsPODetails.Discount3Applied, clsPODetails.Discount3Type); clsPODetails = clsPO.Details(clsDetails.POID); clsPOItem.CommitAndDispose(); UpdateFooter(clsPODetails); }
private void UpdateDeposit() { PODetails clsPODetails = new PODetails(); clsPODetails.POID = Convert.ToInt64(lblPOID.Text); clsPODetails.Deposit = Convert.ToDecimal(txtPODeposit.Text); PO clsPO = new PO(); clsPO.UpdateDeposit(clsPODetails.POID, clsPODetails.Deposit); clsPO.SynchronizeAmount(Convert.ToInt64(lblPOID.Text)); clsPODetails = clsPO.Details(Convert.ToInt64(lblPOID.Text)); clsPO.CommitAndDispose(); UpdateFooter(clsPODetails); }
private void UpdateFooter(PODetails clsPODetails) { lblPODiscount.Text = clsPODetails.Discount.ToString("#,##0.#0"); lblPODiscount2.Text = clsPODetails.Discount2.ToString("#,##0.#0"); lblPODiscount3.Text = clsPODetails.Discount3.ToString("#,##0.#0"); lblTotalDiscount1.Text = Convert.ToDecimal(clsPODetails.SubTotal + clsPODetails.Discount + clsPODetails.Discount2 + clsPODetails.Discount3).ToString("#,##0.#0"); lblTotalDiscount2.Text = Convert.ToDecimal(clsPODetails.SubTotal + clsPODetails.Discount2 + clsPODetails.Discount3).ToString("#,##0.#0"); lblTotalDiscount3.Text = Convert.ToDecimal(clsPODetails.SubTotal + clsPODetails.Discount3).ToString("#,##0.#0"); lblPOVatableAmount.Text = clsPODetails.VatableAmount.ToString("#,##0.#0"); txtPOFreight.Text = clsPODetails.Freight.ToString("#,##0.#0"); txtPODeposit.Text = clsPODetails.Deposit.ToString("#,##0.#0"); lblPOVAT.Text = clsPODetails.VAT.ToString("#,##0.#0"); if (chkIsVatInclusive.Checked) { lblPOSubTotal.Text = Convert.ToDecimal(clsPODetails.SubTotal - clsPODetails.VAT).ToString("#,##0.#0"); lblPOTotal.Text = clsPODetails.SubTotal.ToString("#,##0.#0"); } else { lblPOSubTotal.Text = clsPODetails.SubTotal.ToString("#,##0.#0"); lblPOTotal.Text = Convert.ToDecimal(clsPODetails.SubTotal + clsPODetails.VAT).ToString("#,##0.#0"); } }
public System.Data.DataTable ListAsDataTable(POReturnStatus POReturnStatus = POReturnStatus.All, PODetails searchKey = new PODetails(), DateTime? ReturnStartDate = null, DateTime? ReturnEndDate = null, DateTime? PostingStartDate = null, DateTime? PostingEndDate = null, string SortField = "DebitMemoID", SortOption SortOrder = SortOption.Ascending, Int32 limit = 0, Int64 SupplierID = 0, Int64 DebitMemoID = 0, eSalesFilter clseSalesFilter = new eSalesFilter()) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; // Note WHERE is already included in SQLSelect() string SQL = SQLSelect(); if (POReturnStatus != POReturnStatus.All) { SQL += "AND POReturnStatus = @POReturnStatus "; cmd.Parameters.AddWithValue("@POReturnStatus", POReturnStatus.ToString("d")); } if (DebitMemoID != 0) { SQL += "AND DebitMemoID = @DebitMemoID "; cmd.Parameters.AddWithValue("@DebitMemoID", DebitMemoID); } if (SupplierID != 0) { SQL += "AND SupplierID >= @SupplierID "; cmd.Parameters.AddWithValue("@SupplierID", SupplierID); } if ((ReturnStartDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : ReturnStartDate) != Constants.C_DATE_MIN_VALUE) { SQL += "AND MemoDate >= @ReturnStartDate "; cmd.Parameters.AddWithValue("@ReturnStartDate", ReturnStartDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if ((ReturnEndDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : ReturnEndDate) != Constants.C_DATE_MIN_VALUE) { SQL += "AND MemoDate <= @ReturnEndDate "; cmd.Parameters.AddWithValue("@ReturnEndDate", ReturnEndDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if ((PostingStartDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : PostingStartDate) != Constants.C_DATE_MIN_VALUE) { SQL += "AND PostingDate >= @PostingStartDate "; cmd.Parameters.AddWithValue("@PostingStartDate", PostingStartDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if ((PostingEndDate.GetValueOrDefault() == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : PostingEndDate) != Constants.C_DATE_MIN_VALUE) { SQL += "AND PostingDate <= @PostingEndDate "; cmd.Parameters.AddWithValue("@PostingEndDate", PostingEndDate.Value.ToString("yyyy-MM-dd HH:mm:ss")); } if (clseSalesFilter.FilterIncludeIneSales) { SQL += "AND a.IncludeIneSales = @IncludeIneSales "; cmd.Parameters.AddWithValue("@IncludeIneSales", clseSalesFilter.IncludeIneSales); } SQL += "ORDER BY " + (!string.IsNullOrEmpty(SortField) ? SortField : "DebitMemoID") + " "; SQL += SortOrder == SortOption.Ascending ? "ASC " : "DESC "; SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " "; cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); return dt; } catch (Exception ex) { throw base.ThrowException(ex); } }
private void UpdatePODiscount() { PODetails clsPODetails = new PODetails(); clsPODetails.POID = Convert.ToInt64(lblPOID.Text); clsPODetails.DiscountApplied = Convert.ToDecimal(txtPODiscountApplied.Text); clsPODetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODiscountType.SelectedItem.Value); clsPODetails.Discount2Applied = Convert.ToDecimal(txtPODiscount2Applied.Text); clsPODetails.Discount2Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODiscount2Type.SelectedItem.Value); clsPODetails.Discount3Applied = Convert.ToDecimal(txtPODiscount3Applied.Text); clsPODetails.Discount3Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODiscount3Type.SelectedItem.Value); PO clsPO = new PO(); clsPO.UpdateDiscount(clsPODetails.POID, clsPODetails.DiscountApplied, clsPODetails.DiscountType, clsPODetails.Discount2Applied, clsPODetails.Discount2Type, clsPODetails.Discount3Applied, clsPODetails.Discount3Type); clsPO.SynchronizeAmount(Convert.ToInt64(lblPOID.Text)); clsPODetails = clsPO.Details(Convert.ToInt64(lblPOID.Text)); clsPO.CommitAndDispose(); UpdateFooter(clsPODetails); }
public void Update(PODetails Details) { try { ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction); APLinkConfigDetails clsAPLinkConfigDetails = clsERPConfig.APLinkDetails(); MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL= "UPDATE tblPO SET " + "PONo = @PONo, " + "PODate = @PODate, " + "SupplierID = @SupplierID, " + "SupplierCode = @SupplierCode, " + "SupplierContact = @SupplierContact, " + "SupplierAddress = @SupplierAddress, " + "SupplierTelephoneNo = @SupplierTelephoneNo, " + "SupplierModeOfTerms = @SupplierModeOfTerms, " + "SupplierTerms = @SupplierTerms, " + "SupplierTINNo = @SupplierTINNo, " + "SupplierLTONo = @SupplierLTONo, " + "RequiredDeliveryDate = @RequiredDeliveryDate, " + "RID = @RID, " + "BranchID = @BranchID, " + "PurchaserID = @PurchaserID, " + "PurchaserName = @PurchaserName, " + "Remarks = @Remarks, " + "ChartOfAccountIDAPTracking = @ChartOfAccountIDAPTracking, " + "ChartOfAccountIDAPBills = @ChartOfAccountIDAPBills, " + "ChartOfAccountIDAPFreight = @ChartOfAccountIDAPFreight, " + "ChartOfAccountIDAPVDeposit = @ChartOfAccountIDAPVDeposit, " + "ChartOfAccountIDAPContra = @ChartOfAccountIDAPContra, " + "ChartOfAccountIDAPLatePayment = @ChartOfAccountIDAPLatePayment " + "WHERE POID = @POID;"; cmd.Parameters.AddWithValue("@PONo", Details.PONo); cmd.Parameters.AddWithValue("@PODate", Details.PODate.ToString("yyyy-MM-dd HH:mm:ss")); cmd.Parameters.AddWithValue("@SupplierID", Details.SupplierID); cmd.Parameters.AddWithValue("@SupplierCode", Details.SupplierCode); cmd.Parameters.AddWithValue("@SupplierContact", Details.SupplierContact); cmd.Parameters.AddWithValue("@SupplierAddress", Details.SupplierAddress); cmd.Parameters.AddWithValue("@SupplierTelephoneNo", Details.SupplierTelephoneNo); cmd.Parameters.AddWithValue("@SupplierModeOfTerms", Details.SupplierModeOfTerms); cmd.Parameters.AddWithValue("@SupplierTerms", Details.SupplierTerms); cmd.Parameters.AddWithValue("@SupplierTINNo", Details.SupplierTINNo); cmd.Parameters.AddWithValue("@SupplierLTONo", Details.SupplierLTONo); cmd.Parameters.AddWithValue("@RequiredDeliveryDate", Details.RequiredDeliveryDate.ToString("yyyy-MM-dd HH:mm:ss")); cmd.Parameters.AddWithValue("@RID", Details.RID); cmd.Parameters.AddWithValue("@BranchID", Details.BranchID); cmd.Parameters.AddWithValue("@PurchaserID", Details.PurchaserID); cmd.Parameters.AddWithValue("@PurchaserName", Details.PurchaserName); cmd.Parameters.AddWithValue("@Remarks", Details.Remarks); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPTracking", clsAPLinkConfigDetails.ChartOfAccountIDAPTracking); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPBills", clsAPLinkConfigDetails.ChartOfAccountIDAPBills); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPFreight", clsAPLinkConfigDetails.ChartOfAccountIDAPFreight); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPVDeposit", clsAPLinkConfigDetails.ChartOfAccountIDAPVDeposit); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPContra", clsAPLinkConfigDetails.ChartOfAccountIDAPContra); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPLatePayment", clsAPLinkConfigDetails.ChartOfAccountIDAPLatePayment); cmd.Parameters.AddWithValue("@POID", Details.POID); cmd.CommandText = SQL; base.ExecuteNonQuery(cmd); } catch (Exception ex) { throw base.ThrowException(ex); } }
public long Insert(PODetails Details) { try { ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction); APLinkConfigDetails clsAPLinkConfigDetails = clsERPConfig.APLinkDetails(); MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = "INSERT INTO tblPO (" + "PONo, " + "PODate, " + "SupplierID, " + "SupplierCode, " + "SupplierContact, " + "SupplierAddress, " + "SupplierTelephoneNo, " + "SupplierModeOfTerms, " + "SupplierTerms, " + "SupplierTINNo, " + "SupplierLTONo, " + "RequiredDeliveryDate, " + "RID, " + "BranchID, " + "PurchaserID, " + "PurchaserName, " + "Status, " + "Remarks, " + "ChartOfAccountIDAPTracking, " + "ChartOfAccountIDAPBills, " + "ChartOfAccountIDAPFreight, " + "ChartOfAccountIDAPVDeposit, " + "ChartOfAccountIDAPContra, " + "ChartOfAccountIDAPLatePayment, " + "IncludeIneSales" + ") VALUES (" + "@PONo, " + "@PODate, " + "@SupplierID, " + "@SupplierCode, " + "@SupplierContact, " + "@SupplierAddress, " + "@SupplierTelephoneNo, " + "@SupplierModeOfTerms, " + "@SupplierTerms, " + "@SupplierTINNo, " + "@SupplierLTONo, " + "@RequiredDeliveryDate, " + "@RID, " + "@BranchID, " + "@PurchaserID, " + "@PurchaserName, " + "@Status, " + "@Remarks, " + "@ChartOfAccountIDAPTracking, " + "@ChartOfAccountIDAPBills, " + "@ChartOfAccountIDAPFreight, " + "@ChartOfAccountIDAPVDeposit, " + "@ChartOfAccountIDAPContra, " + "@ChartOfAccountIDAPLatePayment, " + "@IncludeIneSales" + ");"; cmd.Parameters.AddWithValue("@PONo", Details.PONo); cmd.Parameters.AddWithValue("@PODate", Details.PODate.ToString("yyyy-MM-dd HH:mm:ss")); cmd.Parameters.AddWithValue("@SupplierID", Details.SupplierID); cmd.Parameters.AddWithValue("@SupplierCode", Details.SupplierCode); cmd.Parameters.AddWithValue("@SupplierContact", Details.SupplierContact); cmd.Parameters.AddWithValue("@SupplierAddress", Details.SupplierAddress); cmd.Parameters.AddWithValue("@SupplierTelephoneNo", Details.SupplierTelephoneNo); cmd.Parameters.AddWithValue("@SupplierModeOfTerms", Details.SupplierModeOfTerms); cmd.Parameters.AddWithValue("@SupplierTerms", Details.SupplierTerms); cmd.Parameters.AddWithValue("@SupplierTINNo", Details.SupplierTINNo); cmd.Parameters.AddWithValue("@SupplierLTONo", Details.SupplierLTONo); cmd.Parameters.AddWithValue("@RequiredDeliveryDate", Details.RequiredDeliveryDate.ToString("yyyy-MM-dd HH:mm:ss")); cmd.Parameters.AddWithValue("@RID", Details.RID); cmd.Parameters.AddWithValue("@BranchID", Details.BranchID); cmd.Parameters.AddWithValue("@PurchaserID", Details.PurchaserID); cmd.Parameters.AddWithValue("@PurchaserName", Details.PurchaserName); cmd.Parameters.AddWithValue("@Status", Details.Status.ToString("d")); cmd.Parameters.AddWithValue("@Remarks", Details.Remarks); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPTracking", clsAPLinkConfigDetails.ChartOfAccountIDAPTracking); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPBills", clsAPLinkConfigDetails.ChartOfAccountIDAPBills); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPFreight", clsAPLinkConfigDetails.ChartOfAccountIDAPFreight); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPVDeposit", clsAPLinkConfigDetails.ChartOfAccountIDAPVDeposit); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPContra", clsAPLinkConfigDetails.ChartOfAccountIDAPContra); cmd.Parameters.AddWithValue("@ChartOfAccountIDAPLatePayment", clsAPLinkConfigDetails.ChartOfAccountIDAPLatePayment); cmd.Parameters.AddWithValue("@IncludeIneSales", Details.IncludeIneSales); cmd.CommandText = SQL; base.ExecuteNonQuery(cmd); return Int64.Parse(base.getLAST_INSERT_ID(this)); } catch (Exception ex) { throw base.ThrowException(ex); } }
public PODetails Details(long POID) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL= SQLSelect() + "WHERE POID = @POID;"; cmd.Parameters.AddWithValue("@POID", POID); cmd.CommandText = SQL; cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); PODetails Details = new PODetails(); foreach (System.Data.DataRow dr in dt.Rows) { Details.POID = POID; Details.PONo = "" + dr["PONo"].ToString(); Details.PODate = DateTime.Parse(dr["PODate"].ToString()); Details.SupplierID = Int64.Parse(dr["SupplierID"].ToString()); Details.SupplierCode = "" + dr["SupplierCode"].ToString(); Details.SupplierContact = "" + dr["SupplierContact"].ToString(); Details.SupplierAddress = "" + dr["SupplierAddress"].ToString(); Details.SupplierTelephoneNo = "" + dr["SupplierTelephoneNo"].ToString(); Details.SupplierTINNo = "" + dr["SupplierTINNo"].ToString(); Details.SupplierLTONo = "" + dr["SupplierLTONo"].ToString(); Details.SupplierModeOfTerms = Int16.Parse(dr["SupplierModeofTerms"].ToString()); Details.SupplierTerms = Int16.Parse(dr["SupplierTerms"].ToString()); Details.RequiredDeliveryDate = DateTime.Parse(dr["RequiredDeliveryDate"].ToString()); Details.RID = Int64.Parse(dr["RID"].ToString()); Details.BranchID = Int16.Parse(dr["BranchID"].ToString()); Details.BranchCode = "" + dr["BranchCode"].ToString(); Details.BranchName = "" + dr["BranchName"].ToString(); Details.BranchAddress = "" + dr["BranchAddress"].ToString(); Details.PurchaserID = Int64.Parse(dr["PurchaserID"].ToString()); Details.PurchaserName = dr["PurchaserName"].ToString(); Details.SubTotal = Decimal.Parse(dr["SubTotal"].ToString()); Details.Discount = Decimal.Parse(dr["Discount"].ToString()); Details.DiscountApplied = Decimal.Parse(dr["DiscountApplied"].ToString()); Details.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["DiscountType"].ToString()); Details.Discount2 = Decimal.Parse(dr["Discount2"].ToString()); Details.Discount2Applied = Decimal.Parse(dr["Discount2Applied"].ToString()); Details.Discount2Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["Discount2Type"].ToString()); Details.Discount3 = Decimal.Parse(dr["Discount3"].ToString()); Details.Discount3Applied = Decimal.Parse(dr["Discount3Applied"].ToString()); Details.Discount3Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["Discount3Type"].ToString()); Details.VAT = Decimal.Parse(dr["VAT"].ToString()); Details.VatableAmount = Decimal.Parse(dr["VatableAmount"].ToString()); Details.EVAT = Decimal.Parse(dr["EVAT"].ToString()); Details.EVatableAmount = Decimal.Parse(dr["EVatableAmount"].ToString()); Details.LocalTax = Decimal.Parse(dr["LocalTax"].ToString()); Details.Freight = Decimal.Parse(dr["Freight"].ToString()); Details.Deposit = Decimal.Parse(dr["Deposit"].ToString()); Details.PaidAmount = Decimal.Parse(dr["PaidAmount"].ToString()); Details.UnpaidAmount = Decimal.Parse(dr["UnpaidAmount"].ToString()); Details.Status = (POStatus)Enum.Parse(typeof(POStatus), dr["Status"].ToString()); Details.IsVatInclusive = bool.Parse(dr["IsVatInclusive"].ToString()); Details.TotalItemDiscount = Decimal.Parse(dr["TotalItemDiscount"].ToString()); Details.Remarks = dr["Remarks"].ToString(); Details.SupplierDRNo = dr["SupplierDRNo"].ToString(); Details.DeliveryDate = DateTime.Parse(dr["DeliveryDate"].ToString()); Details.ChartOfAccountIDAPTracking = Int16.Parse(dr["ChartOfAccountIDAPTracking"].ToString()); Details.ChartOfAccountIDAPFreight = Int16.Parse(dr["ChartOfAccountIDAPFreight"].ToString()); Details.ChartOfAccountIDAPVDeposit = Int16.Parse(dr["ChartOfAccountIDAPVDeposit"].ToString()); Details.ChartOfAccountIDAPContra = Int16.Parse(dr["ChartOfAccountIDAPContra"].ToString()); Details.ChartOfAccountIDAPLatePayment = Int16.Parse(dr["ChartOfAccountIDAPLatePayment"].ToString()); Details.IncludeIneSales = bool.Parse(dr["IncludeIneSales"].ToString()); } return Details; } catch (Exception ex) { throw base.ThrowException(ex); } }
private void SaveRecord() { PODetails clsDetails = new PODetails(); clsDetails.POID = Convert.ToInt64(lblPOID.Text); clsDetails.PONo = lblPONo.Text; clsDetails.PODate = Convert.ToDateTime(lblPODate.Text); clsDetails.SupplierID = Convert.ToInt64(cboSupplier.SelectedItem.Value); clsDetails.SupplierCode = cboSupplier.SelectedItem.Text; clsDetails.SupplierContact = txtSupplierContact.Text; clsDetails.SupplierAddress = txtSupplierAddress.Text; clsDetails.SupplierTelephoneNo = txtSupplierTelephoneNo.Text; clsDetails.SupplierTINNo = txtSupplierTINNo.Text; clsDetails.SupplierLTONo = txtSupplierLTONo.Text; switch (lblModeOfterms.Text) { case "Days": clsDetails.SupplierModeOfTerms = 0; break; case "Months": clsDetails.SupplierModeOfTerms = 1; break; case "Years": clsDetails.SupplierModeOfTerms = 2; break; } clsDetails.RequiredDeliveryDate = Convert.ToDateTime(txtRequiredDeliveryDate.Text); clsDetails.RID = Convert.ToInt64(txtRID.Text); clsDetails.BranchID = Convert.ToInt16(cboBranch.SelectedItem.Value); clsDetails.PurchaserID = Convert.ToInt64(Session["UID"].ToString()); clsDetails.PurchaserName = Session["Name"].ToString(); clsDetails.Status = POStatus.Open; clsDetails.Remarks = txtRemarks.Text; PO clsPO = new PO(); clsPO.Update(clsDetails); clsPO.CommitAndDispose(); }
private Int64 SaveRecord() { PO clsPO = new PO(); clsPO.GetConnection(); lblPONo.Text = Constants.PURCHASE_ORDER_CODE + CompanyDetails.BECompanyCode + DateTime.Now.Year.ToString() + clsPO.LastTransactionNo(); PODetails clsDetails = new PODetails(); clsDetails.PONo = lblPONo.Text; clsDetails.PODate = Convert.ToDateTime(lblPODate.Text); clsDetails.SupplierID = Convert.ToInt64(cboSupplier.SelectedItem.Value); clsDetails.SupplierCode = cboSupplier.SelectedItem.Text; clsDetails.SupplierContact = txtSupplierContact.Text; clsDetails.SupplierAddress = txtSupplierAddress.Text; clsDetails.SupplierTelephoneNo = txtSupplierTelephoneNo.Text; clsDetails.SupplierTerms = Convert.ToInt32(lblTerms.Text); clsDetails.SupplierTINNo = txtSupplierTINNo.Text; clsDetails.SupplierLTONo = txtSupplierLTONo.Text; switch (lblModeOfterms.Text) { case "Days": clsDetails.SupplierModeOfTerms = 0; break; case "Months": clsDetails.SupplierModeOfTerms = 1; break; case "Years": clsDetails.SupplierModeOfTerms = 2; break; } clsDetails.RequiredDeliveryDate = Convert.ToDateTime(txtRequiredDeliveryDate.Text); clsDetails.RID = Convert.ToInt64(txtRID.Text); clsDetails.BranchID = Convert.ToInt16(cboBranch.SelectedItem.Value); clsDetails.PurchaserID = Convert.ToInt64(Session["UID"].ToString()); clsDetails.PurchaserName = Session["Name"].ToString(); clsDetails.Status = POStatus.Open; clsDetails.Remarks = txtRemarks.Text; bool boIsePurchaseOrder = bool.TryParse(lblIsePurchaseOrder.Text, out boIsePurchaseOrder) ? boIsePurchaseOrder : false; clsDetails.IncludeIneSales = boIsePurchaseOrder; Int64 id = clsPO.Insert(clsDetails); clsPO.CommitAndDispose(); return id; }