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 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 ExportToFile() { DataClass clsDataClass = new DataClass(); PO clsPO = new PO(); PODetails clsPODetails = clsPO.Details(long.Parse(lblPOID.Text)); POItem clsPOItem = new POItem(clsPO.Connection, clsPO.Transaction); DataTable dtaPOItems = clsPOItem.ListAsDataTable(clsPODetails.POID, null, SortOption.Ascending); Branch clsBranch = new Branch(clsPO.Connection, clsPO.Transaction); BranchDetails clsBranchDetails; Contacts clsContact = new Contacts(clsPO.Connection, clsPO.Transaction); ContactDetails clsContactDetails; Products clsProduct = new Products(clsPO.Connection, clsPO.Transaction); ProductDetails clsProductDetails; ProductVariations clsProductVariation = new ProductVariations(clsPO.Connection, clsPO.Transaction); DataTable dtaProductVariation; ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsPO.Connection, clsPO.Transaction); DataTable dtaProductVariationsMatrix; string xmlFileName = Server.MapPath(@"\RetailPlus\temp\" + lblBranchCode.Text.Replace(" ", "").Trim() + "_" + clsPODetails.PONo + "_" + clsPODetails.PODate.ToString("yyyyMMddHHmmssffff") + ".xml"); XmlTextWriter writer = new XmlTextWriter(xmlFileName, System.Text.Encoding.UTF8); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteComment("This file represents the Purchase Order Details of PO No: '" + clsPODetails.PONo + "' 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("PODetails"); writer.WriteAttributeString("POID", XmlConvert.ToString(clsPODetails.POID)); writer.WriteAttributeString("PONo", clsPODetails.PONo); writer.WriteAttributeString("PODate", clsPODetails.PODate.ToString("MM/dd/yyyy HH:mm:ss")); /******Supplier information******/ clsContactDetails = clsContact.Details(clsPODetails.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", clsPODetails.SupplierAddress); writer.WriteAttributeString("SupplierTelephoneNo", clsPODetails.SupplierTelephoneNo); writer.WriteAttributeString("SupplierModeOfTerms", XmlConvert.ToString(clsPODetails.SupplierModeOfTerms)); writer.WriteAttributeString("SupplierTerms", XmlConvert.ToString(clsPODetails.SupplierTerms)); writer.WriteAttributeString("SupplierContactGroupName", clsContactDetails.ContactGroupName); /******End Of Supplier Information******/ writer.WriteAttributeString("RequiredDeliveryDate", clsPODetails.RequiredDeliveryDate.ToString("MM/dd/yyyy HH:mm:ss")); /******Branch & Purchaser Information******/ clsBranchDetails = clsBranch.Details(short.Parse(clsPODetails.BranchID.ToString())); writer.WriteAttributeString("BranchID", XmlConvert.ToString(clsPODetails.BranchID)); writer.WriteAttributeString("BranchCode", clsPODetails.BranchCode); writer.WriteAttributeString("BranchName", clsPODetails.BranchName); writer.WriteAttributeString("BranchAddress", clsPODetails.BranchAddress); writer.WriteAttributeString("BranchDBIP", clsBranchDetails.DBIP); writer.WriteAttributeString("BranchDBPort", clsBranchDetails.DBPort); writer.WriteAttributeString("BranchRemarks", clsBranchDetails.Remarks); writer.WriteAttributeString("PurchaserID", clsPODetails.PurchaserID.ToString()); writer.WriteAttributeString("PurchaserName", clsPODetails.PurchaserName); /******End Of Branch & Purchaser Information******/ /******Amount Information******/ writer.WriteAttributeString("SubTotal", XmlConvert.ToString(clsPODetails.SubTotal)); writer.WriteAttributeString("Discount", XmlConvert.ToString(clsPODetails.Discount)); writer.WriteAttributeString("DiscountApplied", XmlConvert.ToString(clsPODetails.DiscountApplied)); writer.WriteAttributeString("DiscountType", clsPODetails.DiscountType.ToString("d")); writer.WriteAttributeString("VAT", XmlConvert.ToString(clsPODetails.VAT)); writer.WriteAttributeString("VatableAmount", XmlConvert.ToString(clsPODetails.VatableAmount)); writer.WriteAttributeString("EVAT", XmlConvert.ToString(clsPODetails.EVAT)); writer.WriteAttributeString("EVatableAmount", XmlConvert.ToString(clsPODetails.EVatableAmount)); writer.WriteAttributeString("LocalTax", XmlConvert.ToString(clsPODetails.LocalTax)); writer.WriteAttributeString("Freight", XmlConvert.ToString(clsPODetails.Freight)); writer.WriteAttributeString("Deposit", XmlConvert.ToString(clsPODetails.Deposit)); writer.WriteAttributeString("UnpaidAmount", XmlConvert.ToString(clsPODetails.UnpaidAmount)); writer.WriteAttributeString("PaidAmount", XmlConvert.ToString(clsPODetails.PaidAmount)); writer.WriteAttributeString("TotalItemDiscount", XmlConvert.ToString(clsPODetails.TotalItemDiscount)); writer.WriteAttributeString("Status", clsPODetails.Status.ToString("d")); writer.WriteAttributeString("Remarks", clsPODetails.Remarks); writer.WriteAttributeString("SupplierDRNo", clsPODetails.SupplierDRNo); writer.WriteAttributeString("DeliveryDate", clsPODetails.DeliveryDate.ToString("MM/dd/yyyy HH:mm:ss")); writer.WriteAttributeString("CancelledDate", clsPODetails.CancelledDate.ToString("MM/dd/yyyy HH:mm:ss")); writer.WriteAttributeString("CancelledRemarks", clsPODetails.CancelledRemarks); writer.WriteAttributeString("CancelledByID", XmlConvert.ToString(clsPODetails.CancelledByID)); /******End Of Branch Information******/ foreach (DataRow row in dtaPOItems.Rows) { clsProductDetails = new ProductDetails(); clsProductDetails = clsProduct.Details(Convert.ToInt64(row["ProductID"].ToString())); writer.WriteStartElement("POItem"); writer.WriteAttributeString("POItemID", row["POItemID"].ToString()); writer.WriteAttributeString("POID", row["POID"].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("ItemPOItemStatus", row["POItemStatus"].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(); clsPO.CommitAndDispose(); string stScript = "<Script>"; stScript += "window.open('/RetailPlus/temp/" + lblBranchCode.Text.Replace(" ", "").Trim() + "_" + clsPODetails.PONo + "_" + clsPODetails.PODate.ToString("yyyyMMddHHmmssffff") + ".xml')"; stScript += "</Script>"; Response.Write(stScript); }
private void LoadRecord() { Int64 iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["poid"], Session.SessionID)); PO clsPO = new PO(); PODetails clsDetails = clsPO.Details(iID); clsPO.CommitAndDispose(); lblPOID.Text = clsDetails.POID.ToString(); lblPONo.Text = clsDetails.PONo; ///lblPONo.NavigateUrl = "Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&poid=" + Common.Encrypt(clsDetails.POID.ToString(), Session.SessionID); lblPODate.Text = clsDetails.PODate.ToString("yyyy-MM-dd HH:mm:ss"); lblRequiredDeliveryDate.Text = clsDetails.RequiredDeliveryDate.ToString("yyyy-MM-dd"); lblSupplierID.Text = clsDetails.SupplierID.ToString(); lblSupplierCode.Text = clsDetails.SupplierCode.ToString(); string stParam = "?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(clsDetails.SupplierID.ToString(), Session.SessionID); lblSupplierCode.NavigateUrl = "../_Vendor/Default.aspx" + stParam; lblSupplierContact.Text = clsDetails.SupplierContact; lblSupplierTelephoneNo.Text = clsDetails.SupplierTelephoneNo; lblTerms.Text = clsDetails.SupplierTerms.ToString("##0"); switch (clsDetails.SupplierModeOfTerms) { case 0: lblModeOfterms.Text = "Days"; break; case 1: lblModeOfterms.Text = "Months"; break; case 2: lblModeOfterms.Text = "Years"; break; } lblSupplierAddress.Text = clsDetails.SupplierAddress; lblBranchID.Text = clsDetails.BranchID.ToString(); lblBranchCode.Text = clsDetails.BranchCode; lblBranchAddress.Text = clsDetails.BranchAddress; lblPORemarks.Text = clsDetails.Remarks; txtPODiscountApplied.Text = clsDetails.DiscountApplied.ToString("###0.#0"); cboPODiscountType.SelectedIndex = cboPODiscountType.Items.IndexOf(cboPODiscountType.Items.FindByValue(clsDetails.DiscountType.ToString("d"))); lblPODiscount.Text = clsDetails.Discount.ToString("#,##0.#0"); lblTotalDiscount1.Text = Convert.ToDecimal(clsDetails.SubTotal + clsDetails.Discount + clsDetails.Discount2 + clsDetails.Discount3).ToString("#,##0.#0"); txtPODiscount2Applied.Text = clsDetails.Discount2Applied.ToString("###0.#0"); cboPODiscount2Type.SelectedIndex = cboPODiscount2Type.Items.IndexOf(cboPODiscount2Type.Items.FindByValue(clsDetails.Discount2Type.ToString("d"))); lblPODiscount2.Text = clsDetails.Discount2.ToString("#,##0.#0"); lblTotalDiscount2.Text = Convert.ToDecimal(clsDetails.SubTotal + clsDetails.Discount2 + clsDetails.Discount3).ToString("#,##0.#0"); txtPODiscount3Applied.Text = clsDetails.Discount3Applied.ToString("###0.#0"); cboPODiscount3Type.SelectedIndex = cboPODiscount3Type.Items.IndexOf(cboPODiscountType.Items.FindByValue(clsDetails.Discount3Type.ToString("d"))); lblPODiscount3.Text = clsDetails.Discount3.ToString("#,##0.#0"); lblTotalDiscount3.Text = Convert.ToDecimal(clsDetails.SubTotal + clsDetails.Discount3).ToString("#,##0.#0"); lblPOVatableAmount.Text = clsDetails.VatableAmount.ToString("#,##0.#0"); txtPOFreight.Text = clsDetails.Freight.ToString("#,##0.#0"); txtPODeposit.Text = clsDetails.Deposit.ToString("#,##0.#0"); lblPOVAT.Text = clsDetails.VAT.ToString("#,##0.#0"); chkIsVatInclusive.Checked = clsDetails.IsVatInclusive; if (clsDetails.IsVatInclusive) { lblPOSubTotal.Text = Convert.ToDecimal(clsDetails.SubTotal - clsDetails.VAT).ToString("#,##0.#0"); lblPOTotal.Text = clsDetails.SubTotal.ToString("#,##0.#0"); } else { lblPOSubTotal.Text = clsDetails.SubTotal.ToString("#,##0.#0"); lblPOTotal.Text = Convert.ToDecimal(clsDetails.SubTotal + clsDetails.VAT).ToString("#,##0.#0"); } }
protected void chkIncludeIneSales_CheckedChanged(Object sender, EventArgs e) { CheckBox chkIncludeIneSales = (CheckBox)sender; DataListItem item = (DataListItem)chkIncludeIneSales.NamingContainer; HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList"); Int64 iPOID = Int64.Parse(chkList.Value); PO clsPO = new PO(); clsPO.UpdateIncludeIneSales(iPOID, chkIncludeIneSales.Checked); clsPO.CommitAndDispose(); }
private bool DeleteItems() { 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) { POItem clsPOItem = new POItem(); clsPOItem.Delete( stIDs.Substring(0,stIDs.Length-1)); PO clsPO = new PO(clsPOItem.Connection, clsPOItem.Transaction); clsPO.SynchronizeAmount(Convert.ToInt64(lblPOID.Text)); PODetails clsPODetails = clsPO.Details(Convert.ToInt64(lblPOID.Text)); clsPOItem.CommitAndDispose(); UpdateFooter(clsPODetails); } return boRetValue; }
public long Insert(POItemDetails Details) { try { string SQL = "INSERT INTO tblPOItems (" + "POID, " + "ProductID, " + "ProductCode, " + "BarCode, " + "Description, " + "ProductUnitID, " + "ProductUnitCode, " + "Quantity, " + "OriginalQuantity, " + "UnitCost, " + "Discount, " + "DiscountApplied, " + "DiscountType, " + "Amount, " + "VAT, " + "VatableAmount, " + "EVAT, " + "EVatableAmount, " + "LocalTax, " + "isVATInclusive, " + "VariationMatrixID, " + "MatrixDescription, " + "ProductGroup, " + "ProductSubGroup, " + "POItemStatus, " + "IsVatable, " + "Remarks, " + "ChartOfAccountIDPurchase, " + "ChartOfAccountIDTaxPurchase, " + "ChartOfAccountIDInventory," + "SellingPrice," + "SellingVAT," + "SellingEVAT," + "SellingLocalTax," + "OldSellingPrice," + "RID" + ") VALUES (" + "@POID, " + "@ProductID, " + "@ProductCode, " + "@BarCode, " + "@Description, " + "@ProductUnitID, " + "@ProductUnitCode, " + "@Quantity, " + "@Quantity, " + "@UnitCost, " + "@Discount, " + "@DiscountApplied, " + "@DiscountType, " + "@Amount, " + "@VAT, " + "@VatableAmount, " + "@EVAT, " + "@EVatableAmount, " + "@LocalTax, " + "@isVATInclusive, " + "@VariationMatrixID, " + "@MatrixDescription, " + "@ProductGroup, " + "@ProductSubGroup, " + "@POItemStatus, " + "@IsVatable, " + "@Remarks, " + "(SELECT ChartOfAccountIDPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "(SELECT ChartOfAccountIDTaxPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "(SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID)," + "@SellingPrice," + "@SellingVAT," + "@SellingEVAT," + "@SellingLocalTax," + "@OldSellingPrice," + "@RID" + ");"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmPOID = new MySqlParameter("@POID",MySqlDbType.Int64); prmPOID.Value = Details.POID; cmd.Parameters.Add(prmPOID); MySqlParameter prmProductID = new MySqlParameter("@ProductID",MySqlDbType.Int64); prmProductID.Value = Details.ProductID; cmd.Parameters.Add(prmProductID); MySqlParameter prmProductCode = new MySqlParameter("@ProductCode",MySqlDbType.String); prmProductCode.Value = Details.ProductCode; cmd.Parameters.Add(prmProductCode); MySqlParameter prmBarCode = new MySqlParameter("@BarCode",MySqlDbType.String); prmBarCode.Value = Details.BarCode; cmd.Parameters.Add(prmBarCode); MySqlParameter prmDescription = new MySqlParameter("@Description",MySqlDbType.String); prmDescription.Value = Details.Description; cmd.Parameters.Add(prmDescription); MySqlParameter prmProductUnitID = new MySqlParameter("@ProductUnitID",MySqlDbType.Int16); prmProductUnitID.Value = Details.ProductUnitID; cmd.Parameters.Add(prmProductUnitID); MySqlParameter prmProductUnitCode = new MySqlParameter("@ProductUnitCode",MySqlDbType.String); prmProductUnitCode.Value = Details.ProductUnitCode; cmd.Parameters.Add(prmProductUnitCode); MySqlParameter prmQuantity = new MySqlParameter("@Quantity",MySqlDbType.Decimal); prmQuantity.Value = Details.Quantity; cmd.Parameters.Add(prmQuantity); MySqlParameter prmUnitCost = new MySqlParameter("@UnitCost",MySqlDbType.Decimal); prmUnitCost.Value = Details.UnitCost; cmd.Parameters.Add(prmUnitCost); MySqlParameter prmDiscount = new MySqlParameter("@Discount",MySqlDbType.Decimal); prmDiscount.Value = Details.Discount; cmd.Parameters.Add(prmDiscount); MySqlParameter prmDiscountApplied = new MySqlParameter("@DiscountApplied",MySqlDbType.Decimal); prmDiscountApplied.Value = Details.DiscountApplied; cmd.Parameters.Add(prmDiscountApplied); MySqlParameter prmDiscountType = new MySqlParameter("@DiscountType",MySqlDbType.Int16); prmDiscountType.Value = (int) Details.DiscountType; cmd.Parameters.Add(prmDiscountType); MySqlParameter prmAmount = new MySqlParameter("@Amount",MySqlDbType.Decimal); prmAmount.Value = Details.Amount; cmd.Parameters.Add(prmAmount); MySqlParameter prmVAT = new MySqlParameter("@VAT",MySqlDbType.Decimal); prmVAT.Value = Details.VAT; cmd.Parameters.Add(prmVAT); MySqlParameter prmVatableAmount = new MySqlParameter("@VatableAmount",MySqlDbType.Decimal); prmVatableAmount.Value = Details.VatableAmount; cmd.Parameters.Add(prmVatableAmount); MySqlParameter prmEVAT = new MySqlParameter("@EVAT",MySqlDbType.Decimal); prmEVAT.Value = Details.EVAT; cmd.Parameters.Add(prmEVAT); MySqlParameter prmEVatableAmount = new MySqlParameter("@EVatableAmount",MySqlDbType.Decimal); prmEVatableAmount.Value = Details.EVatableAmount; cmd.Parameters.Add(prmEVatableAmount); MySqlParameter prmLocalTax = new MySqlParameter("@LocalTax",MySqlDbType.Decimal); prmLocalTax.Value = Details.LocalTax; cmd.Parameters.Add(prmLocalTax); MySqlParameter prmisVATInclusive = new MySqlParameter("@isVATInclusive",MySqlDbType.Int16); prmisVATInclusive.Value = Convert.ToInt16(Details.isVATInclusive); cmd.Parameters.Add(prmisVATInclusive); MySqlParameter prmVariationMatrixID = new MySqlParameter("@VariationMatrixID",MySqlDbType.Int64); prmVariationMatrixID.Value = Details.VariationMatrixID; cmd.Parameters.Add(prmVariationMatrixID); MySqlParameter prmMatrixDescription = new MySqlParameter("@MatrixDescription",MySqlDbType.String); prmMatrixDescription.Value = Details.MatrixDescription; cmd.Parameters.Add(prmMatrixDescription); MySqlParameter prmProductGroup = new MySqlParameter("@ProductGroup",MySqlDbType.String); prmProductGroup.Value = Details.ProductGroup; cmd.Parameters.Add(prmProductGroup); cmd.Parameters.AddWithValue("@ProductSubGroup", Details.ProductSubGroup); cmd.Parameters.AddWithValue("@POItemStatus", Details.POItemStatus.ToString("d")); cmd.Parameters.AddWithValue("@IsVatable", Convert.ToInt16(Details.IsVatable)); cmd.Parameters.AddWithValue("@Remarks", Details.Remarks); cmd.Parameters.AddWithValue("@SellingPrice", Details.SellingPrice); cmd.Parameters.AddWithValue("@SellingVAT", Details.SellingVAT); cmd.Parameters.AddWithValue("@SellingEVAT", Details.SellingEVAT); cmd.Parameters.AddWithValue("@SellingLocalTax", Details.SellingLocalTax); cmd.Parameters.AddWithValue("@OldSellingPrice", Details.OldSellingPrice); cmd.Parameters.AddWithValue("@RID", Details.RID); base.ExecuteNonQuery(cmd); SQL = "SELECT LAST_INSERT_ID();"; cmd.Parameters.Clear(); 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); Int64 iID = 0; foreach (System.Data.DataRow dr in dt.Rows) { iID = Int64.Parse(dr[0].ToString()); } PO clsPO = new PO(base.Connection, base.Transaction); clsPO.SynchronizeAmount(Details.POID); return iID; } catch (Exception ex) { throw base.ThrowException(ex); } }
private void SavePO() { bool boRetValuePO = false; string stIDs = ""; foreach (DataListItem item in lstPO.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList"); if (chkList != null) { if (chkList.Checked == true) { stIDs += chkList.Value + ","; boRetValuePO = true; } } } if (boRetValuePO) { PO clsPO = new PO(); clsPO.UpdatePaymentStatus(POPaymentStatus.ForProcessing, stIDs.Substring(0, stIDs.Length - 1)); clsPO.CommitAndDispose(); } }
private void PostInvoice() { try { decimal decTotalAmount = Convert.ToDecimal(lblTotalAmount.Text); if (decTotalAmount == 0) { decimal decTotalDebitAmount = Convert.ToDecimal(lblTotalDebitAmount.Text); foreach (DataListItem item in lstPO.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList"); if (chkList != null) { if (chkList.Checked == true) { Label lblUnpaidAmount = (Label)item.FindControl("lblUnpaidAmount"); decimal decUnpaidAmount = Convert.ToDecimal(lblUnpaidAmount.Text); if (decTotalDebitAmount == 0) { break; } else if (decTotalDebitAmount >= decUnpaidAmount) { decTotalDebitAmount -= decUnpaidAmount; } else if (decTotalDebitAmount != 0) { decTotalDebitAmount = 0; break; } } } } if (decTotalDebitAmount > 0) { lblReferrer.Text = "Warning!!! Cannot save the transaction, the Total Amount is greater than the payable amount."; string stScript = "<Script>"; stScript += "window.alert('Warning!!! Cannot save the transaction, the Total Amount is greater than the payable amount.\n Check more Purchase Order(s) to be paid or decrease the Total debit/credit Amount.')"; stScript += "</Script>"; Response.Write(stScript); } else { decTotalDebitAmount = Convert.ToDecimal(lblTotalDebitAmount.Text); DateTime PostingDate = Convert.ToDateTime(txtPostingDate.Text + " " + DateTime.Now.ToString("HH:mm")); long lPaymentID = Convert.ToInt64(lblPaymentID.Text); Payments clsPayments = new Payments(); clsPayments.GetConnection(); PaymentPODetailDetails clsPaymentPODetailDetails; PaymentPODetails clsPaymentPODetails = new PaymentPODetails(clsPayments.Connection, clsPayments.Transaction); PO clsPO = new PO(clsPayments.Connection, clsPayments.Transaction); foreach (DataListItem item in lstPO.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList"); if (chkList != null) { if (chkList.Checked == true) { long lPOID = Convert.ToInt64(chkList.Value); clsPaymentPODetailDetails = new PaymentPODetailDetails(); clsPaymentPODetailDetails.PaymentID = lPaymentID; clsPaymentPODetailDetails.POID = lPOID; Label lblUnpaidAmount = (Label)item.FindControl("lblUnpaidAmount"); decimal decUnpaidAmount = Convert.ToDecimal(lblUnpaidAmount.Text); if (decTotalDebitAmount == 0) { break; } else if (decTotalDebitAmount >= decUnpaidAmount) { clsPO.UpdatePayment(lPOID, decUnpaidAmount, POPaymentStatus.FullyPaid); clsPaymentPODetailDetails.Amount = decUnpaidAmount; clsPaymentPODetailDetails.PaymentStatus = POPaymentStatus.FullyPaid; clsPaymentPODetails.Insert(clsPaymentPODetailDetails); decTotalDebitAmount -= decUnpaidAmount; } else if (decTotalDebitAmount != 0) { clsPO.UpdatePayment(lPOID, decTotalDebitAmount, POPaymentStatus.Partially); clsPaymentPODetailDetails.Amount = decTotalDebitAmount; clsPaymentPODetailDetails.PaymentStatus = POPaymentStatus.Partially; clsPaymentPODetails.Insert(clsPaymentPODetailDetails); decTotalDebitAmount = 0; } } } } clsPayments.Post(lPaymentID, PostingDate); clsPayments.CommitAndDispose(); Response.Redirect("Default.aspx?task=" + Common.Encrypt("list", Session.SessionID)); } } else { //lblReferrer.Text = "Cannot post invoice, the debit/credit amount should be equal. Please check the posted accounts."; string stScript = "<Script>"; stScript += "window.alert('Cannot post invoice, the debit/credit amount should be equal. Please check the posted accounts.')"; stScript += "</Script>"; Response.Write(stScript); } } catch (Exception ex) { lblReferrer.Text= "'Cannot post invoice. unexpected error occurred: " + ex.ToString(); string stScript = "<Script>"; stScript += "window.alert('Cannot post invoice. unexpected error occurred: " + ex.ToString() + "')" ; stScript += "</Script>"; Response.Write(stScript); } }
private void SetDataSource(ReportDocument Report) { long iID = 0; try { if (Request.QueryString["task"].ToString().ToLower() == "reportfromposted" && Request.QueryString["poid"].ToString() != null) { iID = Convert.ToInt64(Request.QueryString["poid"].ToString()); } else { iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["poid"].ToString(), Session.SessionID)); } lblReferrer.ToolTip = iID.ToString(); } catch { iID = long.Parse(lblReferrer.ToolTip); } ReportDataset rptds = new ReportDataset(); PO clsPO = new PO(); System.Data.DataTable dt = clsPO.ListAsDataTable(POID: iID); foreach (System.Data.DataRow dr in dt.Rows) { DataRow drNew = rptds.PO.NewRow(); foreach (DataColumn dc in rptds.PO.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.PO.Rows.Add(drNew); } POItem clsPOItem = new POItem(clsPO.Connection, clsPO.Transaction); dt = clsPOItem.ListAsDataTable(iID); foreach (System.Data.DataRow dr in dt.Rows) { DataRow drNew = rptds.POItems.NewRow(); foreach (DataColumn dc in rptds.POItems.Columns) drNew[dc] = dr[dc.ColumnName]; rptds.POItems.Rows.Add(drNew); } clsPO.CommitAndDispose(); Report.SetDataSource(rptds); SetParameters(Report); }
protected void cboPayee_SelectedIndexChanged(object sender, System.EventArgs e) { long payeeid = Convert.ToInt64(cboPayee.SelectedItem.Value); Data.Contacts clsContact = new Data.Contacts(); Data.ContactDetails clsDetails = clsContact.Details(payeeid); clsContact.CommitAndDispose(); txtPayeeName.Text = clsDetails.ContactName; DataClass clsDataClass = new DataClass(); PO clsPO = new PO(); lstPO.DataSource = clsDataClass.DataReaderToDataTable(clsPO.ListForPayment(payeeid, "POID", SortOption.Ascending)).DefaultView; lstPO.DataBind(); clsPO.CommitAndDispose(); Label lblAmount; Label lblPaidAmount; Label lblUnpaidAmount; decimal decAmount = 0; decimal decPaidAmount = 0; decimal decUnpaidAmount = 0; foreach (DataListItem item in lstPO.Items) { lblAmount = (Label)item.FindControl("lblAmount"); lblPaidAmount = (Label)item.FindControl("lblPaidAmount"); lblUnpaidAmount = (Label)item.FindControl("lblUnpaidAmount"); decAmount += Convert.ToDecimal(lblAmount.Text); decPaidAmount += Convert.ToDecimal(lblPaidAmount.Text); decUnpaidAmount += Convert.ToDecimal(lblUnpaidAmount.Text); } lblPOTotalAmount.Text = decAmount.ToString("#,##0.#0"); lblPOTotalPaidAmount.Text = decPaidAmount.ToString("#,##0.#0"); lblPOTotalUnpaidAmount.Text = decUnpaidAmount.ToString("#,##0.#0"); }
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 void LoadRecord() { Int64 iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["poid"],Session.SessionID)); PO clsPO = new PO(); PODetails clsDetails = clsPO.Details(iID); clsPO.CommitAndDispose(); lblPOID.Text = clsDetails.POID.ToString(); lblPONo.Text = clsDetails.PONo; lblPODate.Text = clsDetails.PODate.ToString("yyyy-MM-dd HH:mm:ss"); txtRequiredDeliveryDate.Text = clsDetails.RequiredDeliveryDate.ToString("yyyy-MM-dd"); txtRID.Text = clsDetails.RID.ToString(); cboSupplier.SelectedIndex = cboSupplier.Items.IndexOf(cboSupplier.Items.FindByValue(clsDetails.SupplierID.ToString())); txtSupplierContact.Text = clsDetails.SupplierContact; txtSupplierTelephoneNo.Text = clsDetails.SupplierTelephoneNo; txtSupplierTINNo.Text = clsDetails.SupplierTINNo; txtSupplierLTONo.Text = clsDetails.SupplierLTONo; lblTerms.Text = clsDetails.SupplierTerms.ToString("##0"); switch (clsDetails.SupplierModeOfTerms) { case 0: lblModeOfterms.Text = "Days"; break; case 1: lblModeOfterms.Text = "Months"; break; case 2: lblModeOfterms.Text = "Years"; break; } txtSupplierAddress.Text = clsDetails.SupplierAddress; cboBranch.SelectedIndex = cboBranch.Items.IndexOf(cboBranch.Items.FindByValue(clsDetails.BranchID.ToString())); txtBranchAddress.Text = clsDetails.BranchAddress; txtRemarks.Text = clsDetails.Remarks; }
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; }
protected void chkIsVatInclusive_CheckedChanged(object sender, EventArgs e) { try { long POID = long.Parse(lblPOID.Text); PO clsPO = new PO(); clsPO.UpdateIsVatInclusive(POID, chkIsVatInclusive.Checked); PODetails clsPODetails = clsPO.Details(POID); clsPO.CommitAndDispose(); UpdateFooter(clsPODetails); } catch (Exception ex) { throw ex; } }
private void IssueGRN() { DateTime DeliveryDate = Convert.ToDateTime(txtDeliveryDate.Text); ERPConfig clsERPConfig = new ERPConfig(); ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details(); clsERPConfig.CommitAndDispose(); if (clsERPConfigDetails.PostingDateFrom <= DeliveryDate && clsERPConfigDetails.PostingDateTo >= DeliveryDate) { long POID = Convert.ToInt64(lblPOID.Text); string SupplierDRNo = txtSupplierDRNo.Text; PO clsPO = new PO(); clsPO.IssueGRN(POID, SupplierDRNo, DeliveryDate); clsPO.CommitAndDispose(); //string stParam = "?task=" + Common.Encrypt("list",Session.SessionID) + "&poid=" + Common.Encrypt(POID.ToString(),Session.SessionID); //Response.Redirect("Default.aspx" + stParam); BackToPOList(); } else { string stScript = "<Script>"; stScript += "window.alert('Sorry you cannot post using the delivery date: " + txtDeliveryDate.Text + ". Please enter an allowable posting date.')"; 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 GenerateItemsByRID() { PO clsPO = new PO(); clsPO.GenerateItemsForReorderByRID(Int32.Parse(Session["TerminalID"].ToString()), Convert.ToInt64(lblPOID.Text), Convert.ToInt64(lblRID.Text), Convert.ToDateTime(txtIDCStartDate.Text + " 00:00:00"), Convert.ToDateTime(txtIDCEndDate.Text + " 23:59:59")); clsPO.CommitAndDispose(); }
public void Update(POItemDetails Details) { try { string SQL= "UPDATE tblPOItems SET " + "POID = @POID, " + "ProductID = @ProductID, " + "ProductCode = @ProductCode, " + "BarCode = @BarCode, " + "Description = @Description, " + "ProductUnitID = @ProductUnitID, " + "ProductUnitCode = @ProductUnitCode, " + "Quantity = @Quantity, " + "OriginalQuantity = @Quantity, " + "UnitCost = @UnitCost, " + "Discount = @Discount, " + "DiscountApplied = @DiscountApplied, " + "DiscountType = @DiscountType, " + "Amount = @Amount, " + "VAT = @VAT, " + "VatableAmount = @VatableAmount, " + "EVAT = @EVAT, " + "EVatableAmount = @EVatableAmount, " + "LocalTax = @LocalTax, " + "isVATInclusive = @isVATInclusive, " + "VariationMatrixID = @VariationMatrixID, " + "MatrixDescription = @MatrixDescription, " + "ProductGroup = @ProductGroup, " + "ProductSubGroup = @ProductSubGroup, " + "POItemStatus = @POItemStatus, " + "IsVatable = @IsVatable, " + "Remarks = @Remarks, " + "ChartOfAccountIDPurchase = (SELECT ChartOfAccountIDPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "ChartOfAccountIDTaxPurchase = (SELECT ChartOfAccountIDTaxPurchase FROM tblProducts WHERE ProductID = @ProductID), " + "ChartOfAccountIDInventory = (SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID), " + "SellingPrice = @SellingPrice, " + "SellingVAT = @SellingVAT, " + "SellingEVAT = @SellingEVAT, " + "SellingLocalTax = @SellingLocalTax, " + "OldSellingPrice = @OldSellingPrice, " + "RID = @RID " + "WHERE POItemID = @POItemID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmPOID = new MySqlParameter("@POID",MySqlDbType.Int64); prmPOID.Value = Details.POID; cmd.Parameters.Add(prmPOID); MySqlParameter prmProductID = new MySqlParameter("@ProductID",MySqlDbType.Int64); prmProductID.Value = Details.ProductID; cmd.Parameters.Add(prmProductID); MySqlParameter prmProductCode = new MySqlParameter("@ProductCode",MySqlDbType.String); prmProductCode.Value = Details.ProductCode; cmd.Parameters.Add(prmProductCode); MySqlParameter prmBarCode = new MySqlParameter("@BarCode",MySqlDbType.String); prmBarCode.Value = Details.BarCode; cmd.Parameters.Add(prmBarCode); MySqlParameter prmDescription = new MySqlParameter("@Description",MySqlDbType.String); prmDescription.Value = Details.Description; cmd.Parameters.Add(prmDescription); MySqlParameter prmProductUnitID = new MySqlParameter("@ProductUnitID",MySqlDbType.Int16); prmProductUnitID.Value = Details.ProductUnitID; cmd.Parameters.Add(prmProductUnitID); MySqlParameter prmProductUnitCode = new MySqlParameter("@ProductUnitCode",MySqlDbType.String); prmProductUnitCode.Value = Details.ProductUnitCode; cmd.Parameters.Add(prmProductUnitCode); MySqlParameter prmQuantity = new MySqlParameter("@Quantity",MySqlDbType.Decimal); prmQuantity.Value = Details.Quantity; cmd.Parameters.Add(prmQuantity); MySqlParameter prmUnitCost = new MySqlParameter("@UnitCost",MySqlDbType.Decimal); prmUnitCost.Value = Details.UnitCost; cmd.Parameters.Add(prmUnitCost); MySqlParameter prmDiscount = new MySqlParameter("@Discount",MySqlDbType.Decimal); prmDiscount.Value = Details.Discount; cmd.Parameters.Add(prmDiscount); MySqlParameter prmDiscountApplied = new MySqlParameter("@DiscountApplied",MySqlDbType.Decimal); prmDiscountApplied.Value = Details.DiscountApplied; cmd.Parameters.Add(prmDiscountApplied); MySqlParameter prmDiscountType = new MySqlParameter("@DiscountType",MySqlDbType.Int16); prmDiscountType.Value = (int)Details.DiscountType; cmd.Parameters.Add(prmDiscountType); MySqlParameter prmAmount = new MySqlParameter("@Amount",MySqlDbType.Decimal); prmAmount.Value = Details.Amount; cmd.Parameters.Add(prmAmount); MySqlParameter prmVAT = new MySqlParameter("@VAT",MySqlDbType.Decimal); prmVAT.Value = Details.VAT; cmd.Parameters.Add(prmVAT); MySqlParameter prmVatableAmount = new MySqlParameter("@VatableAmount",MySqlDbType.Decimal); prmVatableAmount.Value = Details.VatableAmount; cmd.Parameters.Add(prmVatableAmount); MySqlParameter prmEVAT = new MySqlParameter("@EVAT",MySqlDbType.Decimal); prmEVAT.Value = Details.EVAT; cmd.Parameters.Add(prmEVAT); MySqlParameter prmEVatableAmount = new MySqlParameter("@EVatableAmount",MySqlDbType.Decimal); prmEVatableAmount.Value = Details.EVatableAmount; cmd.Parameters.Add(prmEVatableAmount); MySqlParameter prmLocalTax = new MySqlParameter("@LocalTax",MySqlDbType.Decimal); prmLocalTax.Value = Details.LocalTax; cmd.Parameters.Add(prmLocalTax); MySqlParameter prmisVATInclusive = new MySqlParameter("@isVATInclusive",MySqlDbType.Int16); prmisVATInclusive.Value = Convert.ToInt16(Details.isVATInclusive); cmd.Parameters.Add(prmisVATInclusive); MySqlParameter prmVariationMatrixID = new MySqlParameter("@VariationMatrixID",MySqlDbType.Int64); prmVariationMatrixID.Value = Details.VariationMatrixID; cmd.Parameters.Add(prmVariationMatrixID); MySqlParameter prmMatrixDescription = new MySqlParameter("@MatrixDescription",MySqlDbType.String); prmMatrixDescription.Value = Details.MatrixDescription; cmd.Parameters.Add(prmMatrixDescription); MySqlParameter prmProductGroup = new MySqlParameter("@ProductGroup",MySqlDbType.String); prmProductGroup.Value = Details.ProductGroup; cmd.Parameters.Add(prmProductGroup); cmd.Parameters.AddWithValue("@ProductSubGroup", Details.ProductSubGroup); cmd.Parameters.AddWithValue("@POItemStatus", Details.POItemStatus.ToString("d")); cmd.Parameters.AddWithValue("@IsVatable", Convert.ToInt16(Details.IsVatable)); cmd.Parameters.AddWithValue("@Remarks", Details.Remarks); cmd.Parameters.AddWithValue("@SellingPrice", Details.SellingPrice); cmd.Parameters.AddWithValue("@SellingVAT", Details.SellingVAT); cmd.Parameters.AddWithValue("@SellingEVAT", Details.SellingEVAT); cmd.Parameters.AddWithValue("@SellingLocalTax", Details.SellingLocalTax); cmd.Parameters.AddWithValue("@OldSellingPrice", Details.OldSellingPrice); cmd.Parameters.AddWithValue("@RID", Details.RID); cmd.Parameters.AddWithValue("@POItemID", Details.POItemID); base.ExecuteNonQuery(cmd); PO clsPO = new PO(base.Connection, base.Transaction); clsPO.SynchronizeAmount(Details.POID); } catch (Exception ex) { throw base.ThrowException(ex); } }
private void GenerateItemsByThreshold() { PO clsPO = new PO(); clsPO.GenerateItemsForReorder(Int32.Parse(Session["TerminalID"].ToString()), Convert.ToInt64(lblPOID.Text)); clsPO.CommitAndDispose(); }
private void LoadList() { PO clsPO = new PO(); DataClass clsDataClass = new DataClass(); Common Common = new Common(); string SortField = "POID"; if (Request.QueryString["sortfield"]!=null) { SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID); } SortOption sortoption = SortOption.Desscending; if (Request.QueryString["sortoption"]!=null) { sortoption = (SortOption) Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true); } DateTime dteOrderStartDate = DateTime.MinValue; try { if (txtOrderStartDate.Text != string.Empty) dteOrderStartDate = Convert.ToDateTime(txtOrderStartDate.Text + " " + txtOrderStartTime.Text); } catch { } DateTime dteOrderEndDate = DateTime.MinValue; try { if (txtOrderEndDate.Text != string.Empty) dteOrderEndDate = Convert.ToDateTime(txtOrderEndDate.Text + " " + txtOrderEndTime.Text); } catch { } DateTime dtePostingStartDate = DateTime.MinValue; try { if (txtPostingStartDate.Text != string.Empty) dtePostingStartDate = Convert.ToDateTime(txtPostingStartDate.Text + " " + txtPostingStartTime.Text); } catch { } DateTime dtePostingEndDate = DateTime.MinValue; try { if (txtPostingEndDate.Text != string.Empty) dtePostingEndDate = Convert.ToDateTime(txtPostingEndDate.Text + " " + txtPostingEndTime.Text); } catch { } eSalesFilter clseSalesFilter = new eSalesFilter(); clseSalesFilter.FilterIncludeIneSales = true; clseSalesFilter.IncludeIneSales = true; string SearchKey = txtSearch.Text; POStatus status = (POStatus)Enum.Parse(typeof(POStatus), cboStatus.SelectedItem.Value); PageData.DataSource = clsPO.SearchAsDataTable(status, dteOrderStartDate, dteOrderEndDate, dtePostingStartDate, dtePostingEndDate, SearchKey, SortField, sortoption, 0, clseSalesFilter).DefaultView; clsPO.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 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); }
private void CancelPO() { long POID = Convert.ToInt64(lblPOID.Text); string Remarks = txtRemarks.Text; PO clsPO = new PO(); clsPO.Cancel(POID, DateTime.Now, Remarks, Convert.ToInt64(Session["UID"].ToString())); clsPO.CommitAndDispose(); BackToPOList(); }
protected void chkIncludeIneSalesAll_CheckedChanged(Object sender, EventArgs e) { HtmlInputCheckBox chkList = null; CheckBox chkIncludeIneSalesAll = (CheckBox)sender; CheckBox chkIncludeIneSales = null; Int64 iPOID = 0; PO clsPO = new PO(); foreach (DataListItem item in lstItem.Items) { chkList = (HtmlInputCheckBox)item.FindControl("chkList"); iPOID = Int64.Parse(chkList.Value); chkIncludeIneSales = (CheckBox)item.FindControl("chkIncludeIneSales"); clsPO.UpdateIncludeIneSales(iPOID, chkIncludeIneSalesAll.Checked); chkIncludeIneSales.Checked = chkIncludeIneSalesAll.Checked; } clsPO.CommitAndDispose(); }