示例#1
0
		public SalesTransactionItemDetails[] GetItems(DataTable ItemDataTable)
		{
			System.Data.DataTable dt = ItemDataTable;
			int intIndex = 0;

			SalesTransactionItemDetails[] items = new SalesTransactionItemDetails[dt.Rows.Count];

			foreach (System.Data.DataRow dr in dt.Rows)
			{
				SalesTransactionItemDetails Details = new SalesTransactionItemDetails();
 
				Details.ProductID = Convert.ToInt32(dr["ProductID"]);
				Details.ProductCode = Convert.ToString(dr["ProductCode"]);
				Details.BarCode = Convert.ToString(dr["BarCode"]);
				Details.Description = Convert.ToString(dr["Description"]);
				Details.ProductUnitID = Convert.ToInt32(dr["ProductUnitID"]);
				Details.ProductUnitCode = Convert.ToString(dr["ProductUnitCode"]);
				Details.Quantity = Convert.ToInt32(dr["Quantity"]);
				Details.Price = Convert.ToDecimal(dr["Price"]);
				Details.Discount= Convert.ToDecimal(dr["Discount"]);
				Details.Amount = Convert.ToDecimal(dr["Amount"]);
				Details.VariationsMatrixID = Convert.ToInt32(dr["VariationsMatrixID"]);
			
				items[intIndex] = Details;
				intIndex++;
			}
						
			return items;
		}
示例#2
0
        public void UpdateItem(Int64 TransactionID, decimal ItemSold, decimal QuantitySold, decimal GrossSales, decimal SubTotal, decimal NetSales, decimal ItemsDiscount, decimal SNRItemsDiscount, decimal PWDItemsDiscount, decimal OtherItemsDiscount, decimal Discount, decimal SNRDiscount, decimal PWDDiscount, decimal OtherDiscount, decimal TransDiscount, DiscountTypes TransDiscountType, decimal VAT, decimal VATableAmount, decimal ZeroRatedSales, decimal NonVATableAmount, decimal VATExempt, decimal EVAT, decimal EVATableAmount, decimal NonEVATableAmount, decimal LocalTax, string DiscountCode, string DiscountRemarks, decimal Charge, decimal ChargeAmount, string ChargeCode, string ChargeRemarks, ChargeTypes ChargeType, SalesTransactionItemDetails SalesTransItemDetails)
		{
            UpdateSubTotal(TransactionID, ItemSold, QuantitySold, GrossSales, SubTotal, NetSales, ItemsDiscount, SNRItemsDiscount, PWDItemsDiscount, OtherItemsDiscount, Discount, SNRDiscount, PWDDiscount, OtherDiscount, TransDiscount, TransDiscountType, VAT, VATableAmount, ZeroRatedSales, NonVATableAmount, VATExempt, EVAT, EVATableAmount, NonEVATableAmount, LocalTax, DiscountCode, DiscountRemarks, Charge, ChargeAmount, ChargeCode, ChargeRemarks, ChargeType);

            SalesTransactionItems clsSalesTransactionItems = new SalesTransactionItems(base.Connection, base.Transaction);
			clsSalesTransactionItems.Update(SalesTransItemDetails);
		}
示例#3
0
        public Int64 AddItem(Int64 TransactionID, decimal ItemSold, decimal QuantitySold, decimal GrossSales, decimal SubTotal, decimal NetSales, decimal ItemsDiscount, decimal SNRItemsDiscount, decimal PWDItemsDiscount, decimal OtherItemsDiscount, decimal Discount, decimal SNRDiscount, decimal PWDDiscount, decimal OtherDiscount, decimal TransDiscount, DiscountTypes TransDiscountType, decimal VAT, decimal VATableAmount, decimal ZeroRatedSales, decimal NonVATableAmount, decimal VATExempt, decimal EVAT, decimal EVATableAmount, decimal NonEVATableAmount, decimal LocalTax, string DiscountCode, string DiscountRemarks, decimal Charge, decimal ChargeAmount, string ChargeCode, string ChargeRemarks, ChargeTypes ChargeType, SalesTransactionItemDetails SalesTransItemDetails)
		{
			try
			{
                UpdateSubTotal(TransactionID, ItemSold, QuantitySold, GrossSales, SubTotal, NetSales, ItemsDiscount, SNRItemsDiscount, PWDItemsDiscount, OtherItemsDiscount, Discount, SNRDiscount, PWDDiscount, OtherDiscount, TransDiscount, TransDiscountType, VAT, VATableAmount, ZeroRatedSales, NonVATableAmount, VATExempt, EVAT, EVATableAmount, NonEVATableAmount, LocalTax, DiscountCode, DiscountRemarks, Charge, ChargeAmount, ChargeCode, ChargeRemarks, ChargeType);

				SalesTransactionItems clsSalesTransactionItems = new SalesTransactionItems(base.Connection, base.Transaction);
				Int64 TransactionItemID = clsSalesTransactionItems.Insert(SalesTransItemDetails);

				return TransactionItemID;
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}
		}
示例#4
0
		public Int64 AddItem(SalesTransactionDetails SalesTransactionDetails, SalesTransactionItemDetails SalesTransItemDetails)
		{
			try
			{
                UpdateSubTotal(SalesTransactionDetails.TransactionID, SalesTransactionDetails.ItemSold, SalesTransactionDetails.QuantitySold, SalesTransactionDetails.GrossSales, SalesTransactionDetails.SubTotal, SalesTransactionDetails.NetSales, SalesTransactionDetails.ItemsDiscount, SalesTransactionDetails.SNRItemsDiscount, SalesTransactionDetails.PWDItemsDiscount, SalesTransactionDetails.OtherItemsDiscount, SalesTransactionDetails.Discount, SalesTransactionDetails.SNRDiscount, SalesTransactionDetails.PWDDiscount, SalesTransactionDetails.OtherDiscount, SalesTransactionDetails.TransDiscount, SalesTransactionDetails.TransDiscountType, SalesTransactionDetails.VAT, SalesTransactionDetails.VATableAmount, SalesTransactionDetails.ZeroRatedSales, SalesTransactionDetails.NonVATableAmount, SalesTransactionDetails.VATExempt, SalesTransactionDetails.EVAT, SalesTransactionDetails.EVATableAmount, SalesTransactionDetails.NonEVATableAmount, SalesTransactionDetails.LocalTax, SalesTransactionDetails.DiscountCode, SalesTransactionDetails.DiscountRemarks, SalesTransactionDetails.Charge, SalesTransactionDetails.ChargeAmount, SalesTransactionDetails.ChargeCode, SalesTransactionDetails.ChargeRemarks, SalesTransactionDetails.ChargeType);

				SalesTransactionItems clsSalesTransactionItems = new SalesTransactionItems(base.Connection, base.Transaction);
				Int64 TransactionItemID = clsSalesTransactionItems.Insert(SalesTransItemDetails);

				return TransactionItemID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}
		}
        public SalesTransactionItemDetails[] Details(Int64 TransactionID, DateTime TransactionDate)
        {
            try
            {
                
                SalesTransactionItems clsItems = new SalesTransactionItems(base.Connection, base.Transaction);
                System.Data.DataTable  dt = clsItems.List(TransactionID, TransactionDate, "TransactionItemsID", SortOption.Ascending);

                ArrayList items = new ArrayList();
                
                int itemno = 1;
                foreach(System.Data.DataRow dr in dt.Rows)
                {
                    Data.SalesTransactionItemDetails itemDetails = new Data.SalesTransactionItemDetails();

                    itemDetails.ItemNo = itemno.ToString();
                    itemDetails.TransactionItemsID = Int64.Parse(dr["TransactionItemsID"].ToString());
                    itemDetails.ReturnTransactionItemsID = Int64.Parse(dr["ReturnTransactionItemsID"].ToString());
                    itemDetails.RefReturnTransactionItemsID = Int64.Parse(dr["RefReturnTransactionItemsID"].ToString());
                    itemDetails.TransactionID = Int64.Parse(dr["TransactionID"].ToString());
                    itemDetails.ProductID = Int64.Parse(dr["ProductID"].ToString());
                    itemDetails.ProductCode = "" + dr["ProductCode"].ToString();
                    itemDetails.BarCode = "" + dr["BarCode"].ToString();
                    itemDetails.Description = "" + dr["Description"].ToString();
                    itemDetails.ProductUnitID = Int32.Parse(dr["ProductUnitID"].ToString());
                    itemDetails.ProductUnitCode = "" + dr["ProductUnitCode"].ToString();
                    itemDetails.Quantity = decimal.Parse(dr["Quantity"].ToString());
                    itemDetails.Price = decimal.Parse(dr["Price"].ToString());
                    itemDetails.Discount = decimal.Parse(dr["Discount"].ToString());
                    itemDetails.ItemDiscount = decimal.Parse(dr["ItemDiscount"].ToString());
                    itemDetails.ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dr["ItemDiscountType"].ToString());
                    itemDetails.Amount = decimal.Parse(dr["Amount"].ToString());
                    itemDetails.VAT = decimal.Parse(dr["VAT"].ToString());
                    itemDetails.VatableAmount = decimal.Parse(dr["VatableAmount"].ToString());
                    itemDetails.NonVatableAmount = decimal.Parse(dr["NonVatableAmount"].ToString());
                    itemDetails.VATExempt = decimal.Parse(dr["VATExempt"].ToString());
                    itemDetails.EVAT = decimal.Parse(dr["EVAT"].ToString());
                    itemDetails.LocalTax = decimal.Parse(dr["LocalTax"].ToString());
                    itemDetails.VariationsMatrixID = Int64.Parse(dr["VariationsMatrixID"].ToString());
                    itemDetails.MatrixDescription = "" + dr["MatrixDescription"].ToString();
                    itemDetails.ProductGroup = "" + dr["ProductGroup"].ToString();
                    itemDetails.ProductSubGroup = "" + dr["ProductSubGroup"].ToString();
                    itemDetails.TransactionDate = TransactionDate;
                    itemDetails.TransactionItemStatus = (TransactionItemStatus)Enum.Parse(typeof(TransactionItemStatus), dr["TransactionItemStatus"].ToString());
                    itemDetails.DiscountCode = "" + dr["DiscountCode"].ToString();
                    itemDetails.DiscountRemarks = "" + dr["DiscountRemarks"].ToString();
                    itemDetails.ProductPackageID = Int64.Parse(dr["ProductPackageID"].ToString());
                    itemDetails.MatrixPackageID = Int64.Parse(dr["MatrixPackageID"].ToString());
                    itemDetails.PackageQuantity = decimal.Parse(dr["PackageQuantity"].ToString());
                    itemDetails.PromoQuantity = decimal.Parse(dr["PromoQuantity"].ToString());
                    itemDetails.PromoValue = decimal.Parse(dr["PromoValue"].ToString());
                    itemDetails.PromoInPercent = bool.Parse(dr["PromoInPercent"].ToString());
                    itemDetails.PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dr["PromoType"].ToString());
                    itemDetails.PromoApplied = decimal.Parse(dr["PromoApplied"].ToString());
                    itemDetails.PurchasePrice = decimal.Parse(dr["PurchasePrice"].ToString());
                    itemDetails.PurchaseAmount = decimal.Parse(dr["PurchaseAmount"].ToString());
                    itemDetails.IncludeInSubtotalDiscount = bool.Parse(dr["IncludeInSubtotalDiscount"].ToString());
                    itemDetails.IsCreditChargeExcluded = bool.Parse(dr["IsCreditChargeExcluded"].ToString());
                    itemDetails.OrderSlipPrinter1 = bool.Parse(dr["OrderSlipPrinter1"].ToString());
                    itemDetails.OrderSlipPrinter2 = bool.Parse(dr["OrderSlipPrinter2"].ToString());
                    itemDetails.OrderSlipPrinter3 = bool.Parse(dr["OrderSlipPrinter3"].ToString());
                    itemDetails.OrderSlipPrinter4 = bool.Parse(dr["OrderSlipPrinter4"].ToString());
                    itemDetails.OrderSlipPrinter5 = bool.Parse(dr["OrderSlipPrinter5"].ToString());
                    itemDetails.OrderSlipPrinted = Convert.ToBoolean(dr["OrderSlipPrinted"]);
                    itemDetails.PercentageCommision = decimal.Parse(dr["PercentageCommision"].ToString());
                    itemDetails.Commision = decimal.Parse(dr["Commision"].ToString());
                    itemDetails.RewardPoints = decimal.Parse(dr["RewardPoints"].ToString());
                    itemDetails.PaxNo = Int32.Parse(dr["PaxNo"].ToString());
                    itemDetails.SupplierID = Int64.Parse(dr["SupplierID"].ToString());
                    itemDetails.SupplierCode = "" + dr["SupplierCode"].ToString();
                    itemDetails.SupplierName = "" + dr["SupplierName"].ToString();
                    itemDetails.ItemRemarks = "" + dr["ItemRemarks"].ToString();

                    if (itemDetails.TransactionItemStatus == TransactionItemStatus.Return)
                    {
                        itemDetails.Amount = -itemDetails.Amount;
                        itemDetails.Commision = -itemDetails.Commision;
                        itemDetails.RewardPoints = -itemDetails.RewardPoints;
                    }
                    else if (itemDetails.TransactionItemStatus == TransactionItemStatus.Refund)
                    {
                        itemDetails.Amount = -itemDetails.Amount;
                        itemDetails.Commision = -itemDetails.Commision;
                        itemDetails.RewardPoints = -itemDetails.RewardPoints;
                    }
                    else if (itemDetails.TransactionItemStatus == TransactionItemStatus.Void)
                    {
                        itemDetails.Amount = 0;
                        itemDetails.Commision = 0;
                        itemDetails.RewardPoints = 0;
                    }
                    //else
                    //    itemDetails.Amount				= itemDetails.Amount;

                    items.Add(itemDetails);
                    itemno++;
                }

                SalesTransactionItemDetails[] TransactionItems = new SalesTransactionItemDetails[0];

                if (items != null)
                {
                    TransactionItems = new SalesTransactionItemDetails[items.Count];
                    items.CopyTo(TransactionItems);
                }

                return TransactionItems;
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
        public void Update(SalesTransactionItemDetails Details)
        {
            try
            {
                string SQL = "UPDATE tblTransactionItems SET " +
                                "ReturnTransactionItemsID   =   @ReturnTransactionItemsID, " +
                                "TransactionID				=	@TransactionID, " +
                                "ProductID					=	@ProductID, " +
                                "ProductCode				=	@ProductCode, " +
                                "BarCode					=	@BarCode, " +
                                "Description				=	@Description, " +
                                "ProductUnitID				=	@ProductUnitID, " +
                                "ProductUnitCode			=	@ProductUnitCode, " +
                                "Quantity					=	@Quantity, " +
                                "Price						=	@Price, " +
                                "Discount					=	@Discount, " +
                                "ItemDiscount				=	@ItemDiscount, " +
                                "ItemDiscountType			=	@ItemDiscType, " +
                                "GrossSales					=	@GrossSales, " +
                                "Amount						=	@Amount, " +
                                "VAT						=	@VAT, " +
                                "VatableAmount				=	@VatableAmount, " + //GrossSales/(1+(@VAT/100))
                                "NonVatableAmount			=	@NonVatableAmount, " +
                                "VATExempt			        =	@VATExempt, " +
                                "EVAT						=	@EVAT, " +
                                "LocalTax					=	@LocalTax, " +
                                "VariationsMatrixID			=	@VariationsMatrixID,  " +
                                "MatrixDescription			=	@MatrixDescription, " +
                                "ProductGroup				=	@ProductGroup, " +
                                "ProductSubGroup			=	@ProductSubGroup,  " +  
                                "TransactionItemStatus		=	@TransactionItemStatus, " +
                                "DiscountCode				=	@DiscCode,  " +
                                "DiscountRemarks			=	@DiscRemarks, " +
                                "ProductPackageID			=	@ProductPackageID,  " +
                                "MatrixPackageID			=	@MatrixPackageID,  " +
                                "PackageQuantity			=	@PackageQuantity, " +
                                "PromoQuantity				=	@PromoQuantity, " +
                                "PromoValue					=	@PromoValue, " +
                                "PromoInPercent				=	@PromoInPercent, " +
                                "PromoType					=	@PromoType, " +
                                "PromoApplied				=	@PromoApplied, " +
                                "PurchasePrice				=	@PurchasePrice, " +
                                "PurchaseAmount				=	@PurchaseAmount, " +
                                "IncludeInSubtotalDiscount	=	@IncludeInSubtotalDiscount, " +
                                "IsCreditChargeExcluded	    =	@IsCreditChargeExcluded, " +
                                "OrderSlipPrinter1          =   @OrderSlipPrinter1, " +
                                "OrderSlipPrinter2          =   @OrderSlipPrinter2, " +
                                "OrderSlipPrinter3          =   @OrderSlipPrinter3, " +
                                "OrderSlipPrinter4          =   @OrderSlipPrinter4, " +
                                "OrderSlipPrinter5          =   @OrderSlipPrinter5, " +
                                "PercentageCommision        =   @PercentageCommision, " +
                                "Commision                  =   @Commision, " +
                                "RewardPoints               =   @RewardPoints, " +
                                "ItemRemarks                =   @ItemRemarks, " +
                                "LastModified		        =	NOW() " +
                            "WHERE TransactionItemsID		=	@TransactionItemsID; ";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@ReturnTransactionItemsID", Details.ReturnTransactionItemsID);
                cmd.Parameters.AddWithValue("@TransactionID", Details.TransactionID);
                cmd.Parameters.AddWithValue("@ProductID", Details.ProductID);
                cmd.Parameters.AddWithValue("@ProductCode", Details.ProductCode);
                cmd.Parameters.AddWithValue("@BarCode", Details.BarCode);
                cmd.Parameters.AddWithValue("@Description", Details.Description);
                cmd.Parameters.AddWithValue("@ProductUnitID", Details.ProductUnitID);
                cmd.Parameters.AddWithValue("@ProductUnitCode", Details.ProductUnitCode);
                cmd.Parameters.AddWithValue("@Quantity", Details.Quantity);
                cmd.Parameters.AddWithValue("@Price", Details.Price);
                cmd.Parameters.AddWithValue("@Discount", Details.Discount);
                cmd.Parameters.AddWithValue("@ItemDiscount", Details.ItemDiscount);
                cmd.Parameters.AddWithValue("@ItemDiscType", Convert.ToInt16(Details.ItemDiscountType.ToString("d")));
                cmd.Parameters.AddWithValue("@GrossSales", Details.GrossSales);
                cmd.Parameters.AddWithValue("@Amount", Details.Amount);
                cmd.Parameters.AddWithValue("@VAT", Details.VAT);
                cmd.Parameters.AddWithValue("@VatableAmount", Details.VatableAmount); // GrossSales/(1+(@VAT/100))
                cmd.Parameters.AddWithValue("@NonVatableAmount", Details.NonVatableAmount);
                cmd.Parameters.AddWithValue("@VATExempt", Details.VATExempt);
                cmd.Parameters.AddWithValue("@EVAT", Details.EVAT);
                cmd.Parameters.AddWithValue("@LocalTax", Details.LocalTax);
                cmd.Parameters.AddWithValue("@VariationsMatrixID", Details.VariationsMatrixID);
                if (Details.MatrixDescription == null) Details.MatrixDescription = "";
                cmd.Parameters.AddWithValue("@MatrixDescription", Details.MatrixDescription);
                cmd.Parameters.AddWithValue("@ProductGroup", Details.ProductGroup);
                cmd.Parameters.AddWithValue("@ProductSubGroup", Details.ProductSubGroup);
                cmd.Parameters.AddWithValue("@TransactionItemStatus", Convert.ToInt16(Details.TransactionItemStatus.ToString("d")));
                if (Details.DiscountCode == null) Details.DiscountCode = "";
                cmd.Parameters.AddWithValue("@DiscCode", Details.DiscountCode);
                if (Details.DiscountRemarks == null) Details.DiscountRemarks = "";
                cmd.Parameters.AddWithValue("@DiscRemarks", Details.DiscountRemarks);
                cmd.Parameters.AddWithValue("@ProductPackageID", Details.ProductPackageID);
                cmd.Parameters.AddWithValue("@MatrixPackageID", Details.MatrixPackageID);
                cmd.Parameters.AddWithValue("@PackageQuantity", Details.PackageQuantity);
                cmd.Parameters.AddWithValue("@PromoQuantity", Details.PromoQuantity);
                cmd.Parameters.AddWithValue("@PromoValue", Details.PromoValue);
                cmd.Parameters.AddWithValue("@PromoInPercent", Details.PromoInPercent);
                cmd.Parameters.AddWithValue("@PromoType", (int)Details.PromoType);
                cmd.Parameters.AddWithValue("@PromoApplied", Details.PromoApplied);
                cmd.Parameters.AddWithValue("@PurchasePrice", Details.PurchasePrice);
                cmd.Parameters.AddWithValue("@PurchaseAmount", Details.PurchaseAmount);
                cmd.Parameters.AddWithValue("@IncludeInSubtotalDiscount", Details.IncludeInSubtotalDiscount);
                cmd.Parameters.AddWithValue("@IsCreditChargeExcluded", Details.IsCreditChargeExcluded);
                cmd.Parameters.AddWithValue("@OrderSlipPrinter1", Details.OrderSlipPrinter1);
                cmd.Parameters.AddWithValue("@OrderSlipPrinter2", Details.OrderSlipPrinter2);
                cmd.Parameters.AddWithValue("@OrderSlipPrinter3", Details.OrderSlipPrinter3);
                cmd.Parameters.AddWithValue("@OrderSlipPrinter4", Details.OrderSlipPrinter4);
                cmd.Parameters.AddWithValue("@OrderSlipPrinter5", Details.OrderSlipPrinter5);
                cmd.Parameters.AddWithValue("@OrderSlipPrinted", Convert.ToInt16(Details.OrderSlipPrinted));
                cmd.Parameters.AddWithValue("@PercentageCommision", Details.PercentageCommision);
                cmd.Parameters.AddWithValue("@Commision", Details.Commision);
                cmd.Parameters.AddWithValue("@RewardPoints", Details.RewardPoints);
                cmd.Parameters.AddWithValue("@ItemRemarks", Details.ItemRemarks);
                cmd.Parameters.AddWithValue("@TransactionItemsID", Details.TransactionItemsID);

                base.ExecuteNonQuery(cmd);
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
        public Int64 Insert(SalesTransactionItemDetails Details)
        {
            try
            {
                string SQL = "INSERT INTO tblTransactionItems (" +
                                "ReturnTransactionItemsID, " +
                                "TransactionID, " +
                                "ProductID, " +
                                "ProductCode, " +
                                "BarCode, " +
                                "Description, " +
                                "ProductUnitID, " +
                                "ProductUnitCode, " +
                                "Quantity, " +
                                "Price, " +
                                "SellingPrice, " +
                                "Discount, " +
                                "ItemDiscount, " +
                                "ItemDiscountType, " +
                                "GrossSales, " +
                                "Amount, " +
                                "VAT, " +
                                "VatableAmount, " +
                                "NonVatableAmount, " +
                                "VATExempt, " +
                                "EVAT, " +
                                "LocalTax, " +
                                "VariationsMatrixID, " +
                                "MatrixDescription, " +
                                "ProductGroup, " +
                                "ProductSubGroup, " +
                                "TransactionItemStatus," +
                                "DiscountCode," +
                                "DiscountRemarks," +
                                "ProductPackageID," +
                                "MatrixPackageID, " +
                                "PackageQuantity," +
                                "PromoQuantity," +
                                "PromoValue," +
                                "PromoInPercent," +
                                "PromoType," +
                                "PromoApplied," +
                                "PurchasePrice," +
                                "PurchaseAmount," +
                                "IncludeInSubtotalDiscount," +
                                "IsCreditChargeExcluded," +
                                "OrderSlipPrinter1," +
                                "OrderSlipPrinter2," +
                                "OrderSlipPrinter3," +
                                "OrderSlipPrinter4," +
                                "OrderSlipPrinter5," +
                                "OrderSlipPrinted," +
                                "PercentageCommision," +
                                "Commision, RewardPoints, ItemRemarks, PaxNo, " +
                                "SupplierID, SupplierCode, SupplierName, CreatedOn" +
                            ")VALUES(" +
                                "@ReturnTransactionItemsID, " +
                                "@TransactionID, " +
                                "@ProductID, " +
                                "@ProductCode, " +
                                "@BarCode, " +
                                "@Description, " +
                                "@ProductUnitID, " +
                                "@ProductUnitCode, " +
                                "@Quantity, " +
                                "@Price, " +
                                "@Price, " +
                                "@Discount, " +
                                "@ItemDiscount, " +
                                "@ItemDiscType, " +
                                "@GrossSales, " +
                                "@Amount, " +
                                "@VAT, " +
                                "@VatableAmount, " +
                                "@NonVatableAmount, " +
                                "@VATExempt, " +
                                "@EVAT, " +
                                "@LocalTax, " +
                                "@VariationsMatrixID, " +
                                "@MatrixDescription, " +
                                "@ProductGroup, " +
                                "@ProductSubGroup, " +
                                "@TransactionItemStatus," +
                                "@DiscCode, " +
                                "@DiscRemarks, " +
                                "@ProductPackageID," +
                                "@MatrixPackageID, " +
                                "@PackageQuantity," +
                                "@PromoQuantity," +
                                "@PromoValue," +
                                "@PromoInPercent," +
                                "@PromoType," +
                                "@PromoApplied," +
                                "@PurchasePrice," +
                                "@PurchaseAmount," +
                                "@IncludeInSubtotalDiscount," +
                                "@IsCreditChargeExcluded," +
                                "@OrderSlipPrinter1," +
                                "@OrderSlipPrinter2," +
                                "@OrderSlipPrinter3," +
                                "@OrderSlipPrinter4," +
                                "@OrderSlipPrinter5," +
                                "@OrderSlipPrinted," +
                                "@PercentageCommision," +
                                "@Commision, @RewardPoints, @ItemRemarks, @PaxNo, " +
                                "@SupplierID, @SupplierCode, @SupplierName, NOW());";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@ReturnTransactionItemsID", Details.ReturnTransactionItemsID);
                cmd.Parameters.AddWithValue("@TransactionID", Details.TransactionID);
                cmd.Parameters.AddWithValue("@ProductID", Details.ProductID);
                cmd.Parameters.AddWithValue("@ProductCode", Details.ProductCode);
                cmd.Parameters.AddWithValue("@BarCode", Details.BarCode);
                cmd.Parameters.AddWithValue("@Description", Details.Description);
                cmd.Parameters.AddWithValue("@ProductUnitID", Details.ProductUnitID);
                cmd.Parameters.AddWithValue("@ProductUnitCode", Details.ProductUnitCode);
                cmd.Parameters.AddWithValue("@Quantity", Details.Quantity);
                cmd.Parameters.AddWithValue("@Price", Details.Price);
                cmd.Parameters.AddWithValue("@Discount", Details.Discount);
                cmd.Parameters.AddWithValue("@ItemDiscount", Details.ItemDiscount);
                cmd.Parameters.AddWithValue("@ItemDiscType", Convert.ToInt16(Details.ItemDiscountType.ToString("d")));
                cmd.Parameters.AddWithValue("@GrossSales", Details.GrossSales);
                cmd.Parameters.AddWithValue("@Amount", Details.Amount);
                cmd.Parameters.AddWithValue("@VAT", Details.VAT);
                cmd.Parameters.AddWithValue("@VatableAmount", Details.VatableAmount); //GrossSales/(1+(@VAT/100))
                cmd.Parameters.AddWithValue("@NonVatableAmount", Details.NonVatableAmount);
                cmd.Parameters.AddWithValue("@VATExempt", Details.VATExempt);
                cmd.Parameters.AddWithValue("@EVAT", Details.EVAT);
                cmd.Parameters.AddWithValue("@LocalTax", Details.LocalTax);
                cmd.Parameters.AddWithValue("@VariationsMatrixID", Details.VariationsMatrixID);
                if (Details.MatrixDescription == null) Details.MatrixDescription = "";
                cmd.Parameters.AddWithValue("@MatrixDescription", Details.MatrixDescription);
                cmd.Parameters.AddWithValue("@ProductGroup", Details.ProductGroup);
                cmd.Parameters.AddWithValue("@ProductSubGroup", Details.ProductSubGroup);
                cmd.Parameters.AddWithValue("@TransactionItemStatus", Convert.ToInt16(Details.TransactionItemStatus.ToString("d")));
                if (Details.DiscountCode == null) Details.DiscountCode = "";
                cmd.Parameters.AddWithValue("@DiscCode", Details.DiscountCode);
                if (Details.DiscountRemarks == null) Details.DiscountRemarks = "";
                cmd.Parameters.AddWithValue("@DiscRemarks", Details.DiscountRemarks);
                cmd.Parameters.AddWithValue("@ProductPackageID", Details.ProductPackageID);
                cmd.Parameters.AddWithValue("@MatrixPackageID", Details.MatrixPackageID);
                cmd.Parameters.AddWithValue("@PackageQuantity", Details.PackageQuantity);
                cmd.Parameters.AddWithValue("@PromoQuantity", Details.PromoQuantity);
                cmd.Parameters.AddWithValue("@PromoValue", Details.PromoValue);
                cmd.Parameters.AddWithValue("@PromoInPercent", Details.PromoInPercent);
                cmd.Parameters.AddWithValue("@PromoType", (int)Details.PromoType);
                cmd.Parameters.AddWithValue("@PromoApplied", Details.PromoApplied);
                cmd.Parameters.AddWithValue("@PurchasePrice", Details.PurchasePrice);
                cmd.Parameters.AddWithValue("@PurchaseAmount", Details.PurchaseAmount);
                cmd.Parameters.AddWithValue("@IncludeInSubtotalDiscount", Details.IncludeInSubtotalDiscount);
                cmd.Parameters.AddWithValue("@IsCreditChargeExcluded", Details.IsCreditChargeExcluded);
                cmd.Parameters.AddWithValue("@OrderSlipPrinter1", Details.OrderSlipPrinter1);
                cmd.Parameters.AddWithValue("@OrderSlipPrinter2", Details.OrderSlipPrinter2);
                cmd.Parameters.AddWithValue("@OrderSlipPrinter3", Details.OrderSlipPrinter3);
                cmd.Parameters.AddWithValue("@OrderSlipPrinter4", Details.OrderSlipPrinter4);
                cmd.Parameters.AddWithValue("@OrderSlipPrinter5", Details.OrderSlipPrinter5);
                cmd.Parameters.AddWithValue("@OrderSlipPrinted", Convert.ToInt16(Details.OrderSlipPrinted));
                cmd.Parameters.AddWithValue("@PercentageCommision", Details.PercentageCommision);
                cmd.Parameters.AddWithValue("@Commision", Details.Commision);
                cmd.Parameters.AddWithValue("@RewardPoints", Details.RewardPoints);
                cmd.Parameters.AddWithValue("@ItemRemarks", Details.ItemRemarks);
                cmd.Parameters.AddWithValue("@PaxNo", Details.PaxNo);
                cmd.Parameters.AddWithValue("@SupplierID", Details.SupplierID);
                cmd.Parameters.AddWithValue("@SupplierCode", Details.SupplierCode);
                cmd.Parameters.AddWithValue("@SupplierName", Details.SupplierName);

                base.ExecuteNonQuery(cmd);

                SQL = "SELECT LAST_INSERT_ID();";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;

                Int64 iID = Int64.Parse(base.getLAST_INSERT_ID(this));

                return iID;
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
        private void CreateDetails(int iRow)
        {
            try
            {
                mDetails = new Data.SalesTransactionItemDetails();

                mDetails.TransactionItemsID = Convert.ToInt64(dgItems[iRow, 0]);
                mDetails.ProductID = Convert.ToInt64(dgItems[iRow, 1]);
                mDetails.ProductCode = dgItems[iRow, 2].ToString();
                mDetails.BarCode = dgItems[iRow, 3].ToString();
                mDetails.Description = dgItems[iRow, 4].ToString();
                mDetails.ProductUnitID = Convert.ToInt32(dgItems[iRow, 5].ToString());
                mDetails.ProductUnitCode = dgItems[iRow, 6].ToString();
                mDetails.Quantity = Convert.ToDecimal(dgItems[iRow, 7].ToString());
                mDetails.Price = Convert.ToDecimal(dgItems[iRow, 8].ToString());
                mDetails.Discount = Convert.ToDecimal(dgItems[iRow, 9].ToString());
                mDetails.ItemDiscount = Convert.ToDecimal(dgItems[iRow, 10].ToString());
                mDetails.ItemDiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), dgItems[iRow, 11].ToString());
                mDetails.Amount = Convert.ToDecimal(dgItems[iRow, 12].ToString());
                mDetails.VAT = Convert.ToDecimal(dgItems[iRow, 13].ToString());
                mDetails.EVAT = Convert.ToDecimal(dgItems[iRow, 14].ToString());
                mDetails.LocalTax = Convert.ToDecimal(dgItems[iRow, 15].ToString());
                mDetails.VariationsMatrixID = Convert.ToInt64(dgItems[iRow, 16]);
                mDetails.MatrixDescription = dgItems[iRow, 17].ToString();
                mDetails.ProductGroup = dgItems[iRow, 18].ToString();
                mDetails.ProductSubGroup = dgItems[iRow, 19].ToString();
                mDetails.TransactionItemStatus = (TransactionItemStatus)Enum.Parse(typeof(TransactionItemStatus), dgItems[iRow, 20].ToString());
                mDetails.DiscountCode = dgItems[iRow, 21].ToString();
                mDetails.DiscountRemarks = dgItems[iRow, 22].ToString();
                mDetails.ProductPackageID = Convert.ToInt64(dgItems[iRow, 23]);
                mDetails.MatrixPackageID = Convert.ToInt64(dgItems[iRow, 24]);
                mDetails.PackageQuantity = Convert.ToDecimal(dgItems[iRow, 25]);
                mDetails.PromoQuantity = Convert.ToDecimal(dgItems[iRow, 26]);
                mDetails.PromoValue = Convert.ToDecimal(dgItems[iRow, 27]);
                mDetails.PromoInPercent = Convert.ToBoolean(dgItems[iRow, 28].ToString());
                mDetails.PromoType = (PromoTypes)Enum.Parse(typeof(PromoTypes), dgItems[iRow, 29].ToString());
                mDetails.PromoApplied = Convert.ToDecimal(dgItems[iRow, 30]);
                mDetails.PurchasePrice = Convert.ToDecimal(dgItems[iRow, 31]);
                mDetails.PurchaseAmount = Convert.ToDecimal(dgItems[iRow, 32]);
                mDetails.SupplierID = Convert.ToInt64(dgItems[iRow, 33]);
                mDetails.SupplierCode = dgItems[iRow, 34].ToString();
                mDetails.SupplierName = dgItems[iRow, 35].ToString();
                mDetails.ItemRemarks = dgItems[iRow, 36].ToString();
                mDetails.ReturnTransactionItemsID = Convert.ToInt64(dgItems[iRow, 0]);
            }
            catch (Exception ex)
            {
                Event clsEvent = new Event();
                clsEvent.AddEventLn("Application error. TRACE: " + ex.Message);
                clsEvent.AddEventLn("SOURCE: " + ex.Source, false);
                clsEvent.AddEventLn("STACK TRACE: " + ex.StackTrace, false);
                throw ex;
            }
        }
		private void CreateDetails(int iRow)
		{
			mDetails = new Data.SalesTransactionItemDetails();

			mDetails.ProductID = Convert.ToInt32(dgItems[iRow, 0]);
			mDetails.ProductCode = dgItems[iRow, 1].ToString();
			mDetails.BarCode = dgItems[iRow, 2].ToString();
			mDetails.Description = dgItems[iRow, 3].ToString();
			mDetails.ProductGroup = dgItems[iRow, 4].ToString();
			mDetails.ProductSubGroup = dgItems[iRow, 5].ToString();
			mDetails.ProductUnitID = Convert.ToInt32(dgItems[iRow, 6].ToString());
			mDetails.ProductUnitCode = dgItems[iRow, 7].ToString();
			mDetails.Quantity = Convert.ToDecimal(dgItems[iRow, 8].ToString());
			mDetails.Price = Convert.ToDecimal(dgItems[iRow, 9].ToString());
			mDetails.Discount = Convert.ToDecimal(dgItems[iRow, 10].ToString());
			mDetails.VAT = Convert.ToDecimal(dgItems[iRow, 11].ToString());
			mDetails.EVAT = Convert.ToDecimal(dgItems[iRow, 12].ToString());
			mDetails.LocalTax = Convert.ToDecimal(dgItems[iRow, 13].ToString());
			mDetails.Amount = (mDetails.Quantity * mDetails.Price) - (mDetails.Quantity * mDetails.Discount);
		}