public long Insert(ClosingItemDetails Details) { try { string SQL = "INSERT INTO tblClosingItems (" + "ClosingID, " + "ProductID, " + "ProductCode, " + "BarCode, " + "Description, " + "ProductUnitID, " + "ProductUnitCode, " + "Quantity, " + "UnitCost, " + "Discount, " + "InPercent, " + "TotalDiscount, " + "Amount, " + "VAT, " + "VatableAmount, " + "EVAT, " + "EVatableAmount, " + "LocalTax, " + "VariationMatrixID, " + "MatrixDescription, " + "ProductGroup, " + "ProductSubGroup, " + "ClosingItemStatus, " + "IsVatable, " + "Remarks" + ") VALUES (" + "@ClosingID, " + "@ProductID, " + "@ProductCode, " + "@BarCode, " + "@Description, " + "@ProductUnitID, " + "@ProductUnitCode, " + "@Quantity, " + "@UnitCost, " + "@Discount, " + "@InPercent, " + "@TotalDiscount, " + "@Amount, " + "@VAT, " + "@VatableAmount, " + "@EVAT, " + "@EVatableAmount, " + "@LocalTax, " + "@VariationMatrixID, " + "@MatrixDescription, " + "@ProductGroup, " + "@ProductSubGroup, " + "@ClosingItemStatus, " + "@IsVatable, " + "@Remarks" + ");"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmClosingID = new MySqlParameter("@ClosingID",MySqlDbType.Int64); prmClosingID.Value = Details.ClosingID; cmd.Parameters.Add(prmClosingID); 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 prmInPercent = new MySqlParameter("@InPercent",MySqlDbType.Int16); prmInPercent.Value = Convert.ToInt16(Details.InPercent); cmd.Parameters.Add(prmInPercent); MySqlParameter prmTotalDiscount = new MySqlParameter("@TotalDiscount",MySqlDbType.Decimal); prmTotalDiscount.Value = Details.TotalDiscount; cmd.Parameters.Add(prmTotalDiscount); 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 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); MySqlParameter prmProductSubGroup = new MySqlParameter("@ProductSubGroup",MySqlDbType.String); prmProductSubGroup.Value = Details.ProductSubGroup; cmd.Parameters.Add(prmProductSubGroup); MySqlParameter prmClosingItemStatus = new MySqlParameter("@ClosingItemStatus",MySqlDbType.Int16); prmClosingItemStatus.Value = Details.ClosingItemStatus.ToString("d"); cmd.Parameters.Add(prmClosingItemStatus); MySqlParameter prmIsVatable = new MySqlParameter("@IsVatable",MySqlDbType.Int16); prmIsVatable.Value = Details.IsVatable; cmd.Parameters.Add(prmIsVatable); MySqlParameter prmRemarks = new MySqlParameter("@Remarks",MySqlDbType.String); prmRemarks.Value = Details.Remarks; cmd.Parameters.Add(prmRemarks); 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()); } Closing clsClosing = new Closing(base.Connection, base.Transaction); clsClosing.SynchronizeAmount(Details.ClosingID); return iID; } catch (Exception ex) { throw base.ThrowException(ex); } }
public void GenerateItemsForReorder(Int32 TerminalID, Int64 ClosingID) { try { GetConnection(); Terminal clsTerminal = new Terminal(base.Connection, base.Transaction); TerminalDetails clsTerminalDetails = clsTerminal.Details(TerminalID); ClosingDetails clsClosingDetails = Details(ClosingID); Products clsProduct = new Products(base.Connection, base.Transaction); System.Data.DataTable dt = clsProduct.ForReorder(clsClosingDetails.SupplierID); ClosingItem clsClosingItem = new ClosingItem(base.Connection, base.Transaction); ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction); foreach(System.Data.DataRow dr in dt.Rows) { ClosingItemDetails clsDetails = new ClosingItemDetails(); clsDetails.ClosingID = ClosingID; clsDetails.ProductID = Convert.ToInt64(dr["ProductID"]); clsDetails.ProductCode = dr["ProductCode"].ToString(); clsDetails.BarCode = dr["BarCode"].ToString(); clsDetails.Description = dr["ProductDesc"].ToString(); clsDetails.ProductGroup = dr["ProductGroupCode"].ToString(); clsDetails.ProductSubGroup = dr["ProductSubGroupCode"].ToString(); clsDetails.ProductUnitID = Convert.ToInt32(dr["UnitID"].ToString()); clsDetails.ProductUnitCode = dr["UnitName"].ToString(); clsDetails.Quantity = Convert.ToDecimal(dr["ReorderQty"].ToString()); clsDetails.UnitCost = Convert.ToDecimal(dr["Price"].ToString()); clsDetails.Discount = 0; clsDetails.InPercent = false; clsDetails.TotalDiscount = 0; clsDetails.Remarks = "added using auto generation"; decimal amount = clsDetails.Quantity * clsDetails.UnitCost; if (Convert.ToDecimal(dr["VAT"]) > 0) { clsDetails.VatableAmount = amount; clsDetails.EVatableAmount = amount; clsDetails.LocalTax = amount; clsDetails.VAT = clsDetails.VatableAmount * (clsTerminalDetails.VAT / 100); clsDetails.EVAT = clsDetails.EVatableAmount * (clsTerminalDetails.EVAT / 100); clsDetails.LocalTax = clsDetails.LocalTax * (clsTerminalDetails.LocalTax / 100); clsDetails.IsVatable = true; } else { clsDetails.VAT = 0; clsDetails.VatableAmount = 0; clsDetails.EVAT = 0; clsDetails.EVatableAmount = 0; clsDetails.LocalTax = 0; clsDetails.IsVatable = false; } clsDetails.Amount = amount + clsDetails.VAT; System.Data.DataTable dtmatrix = clsProductVariationsMatrix.ForReorder(clsDetails.ProductID, clsClosingDetails.SupplierID); if (dtmatrix.Rows.Count > 0) foreach(System.Data.DataRow drmatrix in dtmatrix.Rows) { amount = clsDetails.Quantity * clsDetails.UnitCost; clsDetails.ProductUnitID = Convert.ToInt32(drmatrix["UnitID"]); clsDetails.ProductUnitCode = drmatrix["UnitName"].ToString(); clsDetails.Quantity = Convert.ToDecimal(drmatrix["ReorderQty"]); clsDetails.UnitCost = Convert.ToDecimal(drmatrix["Price"]); if (Convert.ToDecimal(drmatrix["VAT"]) > 0) { clsDetails.VatableAmount = amount; clsDetails.EVatableAmount = amount; clsDetails.LocalTax = amount; clsDetails.VAT = clsDetails.VatableAmount * (clsTerminalDetails.VAT / 100); clsDetails.EVAT = clsDetails.EVatableAmount * (clsTerminalDetails.EVAT / 100); clsDetails.LocalTax = clsDetails.LocalTax * (clsTerminalDetails.LocalTax / 100); clsDetails.IsVatable = true; } else { clsDetails.VAT = 0; clsDetails.VatableAmount = 0; clsDetails.EVAT = 0; clsDetails.EVatableAmount = 0; clsDetails.LocalTax = 0; clsDetails.IsVatable = false; } clsDetails.Amount = amount + clsDetails.VAT; clsDetails.VariationMatrixID = Convert.ToInt64(drmatrix["MatrixID"]); clsDetails.MatrixDescription = drmatrix["VariationDesc"].ToString(); clsClosingItem.Insert(clsDetails); } else { clsDetails.VariationMatrixID = 0; clsDetails.MatrixDescription = string.Empty; clsClosingItem.Insert(clsDetails); } } } catch (Exception ex) { throw base.ThrowException(ex); } }
public ClosingItemDetails Details(long ClosingItemID) { try { string SQL= "SELECT " + "ClosingItemID, " + "ClosingID, " + "ProductID, " + "ProductCode, " + "BarCode, " + "Description, " + "ProductUnitID, " + "ProductUnitCode, " + "Quantity, " + "UnitCost, " + "Discount, " + "InPercent, " + "TotalDiscount, " + "Amount, " + "VAT, " + "VatableAmount, " + "EVAT, " + "EVatableAmount, " + "LocalTax, " + "VariationMatrixID, " + "MatrixDescription, " + "ProductGroup, " + "ProductSubGroup, " + "ClosingItemStatus, " + "IsVatable, " + "Remarks " + "FROM tblClosingItems " + "WHERE ClosingItemID = @ClosingItemID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmClosingItemID = new MySqlParameter("@ClosingItemID",MySqlDbType.Int64); prmClosingItemID.Value = ClosingItemID; cmd.Parameters.Add(prmClosingItemID); MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult); ClosingItemDetails Details = new ClosingItemDetails(); while (myReader.Read()) { Details.ClosingItemID = ClosingItemID; Details.ClosingID = myReader.GetInt64("ClosingID"); Details.ProductID = myReader.GetInt64("ProductID"); Details.ProductCode = "" + myReader["ProductCode"].ToString(); Details.BarCode = "" + myReader["BarCode"].ToString(); Details.Description = "" + myReader["Description"].ToString(); Details.ProductUnitID = myReader.GetInt16("ProductUnitID"); Details.ProductUnitCode = "" + myReader["ProductUnitCode"].ToString(); Details.Quantity = myReader.GetDecimal("Quantity"); Details.UnitCost = myReader.GetDecimal("UnitCost"); Details.Discount = myReader.GetDecimal("Discount"); if (myReader["InPercent"].ToString() == "1") Details.InPercent = true; Details.TotalDiscount = myReader.GetDecimal("TotalDiscount"); Details.Amount = myReader.GetDecimal("Amount"); Details.VAT = myReader.GetDecimal("VAT"); Details.VatableAmount = myReader.GetDecimal("VatableAmount"); Details.EVAT = myReader.GetDecimal("EVAT"); Details.EVatableAmount = myReader.GetDecimal("EVatableAmount"); Details.LocalTax = myReader.GetDecimal("LocalTax"); Details.VariationMatrixID = myReader.GetInt64("VariationMatrixID"); Details.MatrixDescription = "" + myReader["MatrixDescription"].ToString(); Details.ProductGroup = "" + myReader["ProductGroup"].ToString(); Details.ProductSubGroup = "" + myReader["ProductSubGroup"].ToString(); Details.ClosingItemStatus = (ClosingItemStatus)Enum.Parse(typeof(ClosingItemStatus), myReader.GetString("ClosingItemStatus")); if (myReader["IsVatable"].ToString() == "1") Details.IsVatable = true; Details.Remarks = "" + myReader["Remarks"].ToString(); } myReader.Close(); return Details; } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(ClosingItemDetails Details) { try { string SQL= "UPDATE tblClosingItems SET " + "ClosingID = @ClosingID, " + "ProductID = @ProductID, " + "ProductCode = @ProductCode, " + "BarCode = @BarCode, " + "Description = @Description, " + "ProductUnitID = @ProductUnitID, " + "ProductUnitCode = @ProductUnitCode, " + "Quantity = @Quantity, " + "UnitCost = @UnitCost, " + "Discount = @Discount, " + "InPercent = @InPercent, " + "TotalDiscount = @TotalDiscount, " + "Amount = @Amount, " + "VAT = @VAT, " + "VatableAmount = @VatableAmount, " + "EVAT = @EVAT, " + "EVatableAmount = @EVatableAmount, " + "LocalTax = @LocalTax, " + "VariationMatrixID = @VariationMatrixID, " + "MatrixDescription = @MatrixDescription, " + "ProductGroup = @ProductGroup, " + "ProductSubGroup = @ProductSubGroup, " + "ClosingItemStatus = @ClosingItemStatus, " + "IsVatable = @IsVatable, " + "Remarks = @Remarks " + "WHERE ClosingItemID = @ClosingItemID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmClosingID = new MySqlParameter("@ClosingID",MySqlDbType.Int64); prmClosingID.Value = Details.ClosingID; cmd.Parameters.Add(prmClosingID); 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 prmInPercent = new MySqlParameter("@InPercent",MySqlDbType.Int16); prmInPercent.Value = Convert.ToInt16(Details.InPercent); cmd.Parameters.Add(prmInPercent); MySqlParameter prmTotalDiscount = new MySqlParameter("@TotalDiscount",MySqlDbType.Decimal); prmTotalDiscount.Value = Details.TotalDiscount; cmd.Parameters.Add(prmTotalDiscount); 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 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); MySqlParameter prmProductSubGroup = new MySqlParameter("@ProductSubGroup",MySqlDbType.String); prmProductSubGroup.Value = Details.ProductSubGroup; cmd.Parameters.Add(prmProductSubGroup); MySqlParameter prmClosingItemStatus = new MySqlParameter("@ClosingItemStatus",MySqlDbType.Int16); prmClosingItemStatus.Value = Details.ClosingItemStatus.ToString("d"); cmd.Parameters.Add(prmClosingItemStatus); MySqlParameter prmIsVatable = new MySqlParameter("@IsVatable",MySqlDbType.Int16); prmIsVatable.Value = Details.IsVatable; cmd.Parameters.Add(prmIsVatable); MySqlParameter prmRemarks = new MySqlParameter("@Remarks",MySqlDbType.String); prmRemarks.Value = Details.Remarks; cmd.Parameters.Add(prmRemarks); MySqlParameter prmClosingItemID = new MySqlParameter("@ClosingItemID",MySqlDbType.Int64); prmClosingItemID.Value = Details.ClosingItemID; cmd.Parameters.Add(prmClosingItemID); base.ExecuteNonQuery(cmd); Closing clsClosing = new Closing(base.Connection, base.Transaction); clsClosing.SynchronizeAmount(Details.ClosingID); } catch (Exception ex) { throw base.ThrowException(ex); } }
public long Insert(ClosingItemDetails Details) { try { string SQL = "INSERT INTO tblClosingItems (" + "ClosingID, " + "ProductID, " + "ProductCode, " + "BarCode, " + "Description, " + "ProductUnitID, " + "ProductUnitCode, " + "Quantity, " + "UnitCost, " + "Discount, " + "InPercent, " + "TotalDiscount, " + "Amount, " + "VAT, " + "VatableAmount, " + "EVAT, " + "EVatableAmount, " + "LocalTax, " + "VariationMatrixID, " + "MatrixDescription, " + "ProductGroup, " + "ProductSubGroup, " + "ClosingItemStatus, " + "IsVatable, " + "Remarks" + ") VALUES (" + "@ClosingID, " + "@ProductID, " + "@ProductCode, " + "@BarCode, " + "@Description, " + "@ProductUnitID, " + "@ProductUnitCode, " + "@Quantity, " + "@UnitCost, " + "@Discount, " + "@InPercent, " + "@TotalDiscount, " + "@Amount, " + "@VAT, " + "@VatableAmount, " + "@EVAT, " + "@EVatableAmount, " + "@LocalTax, " + "@VariationMatrixID, " + "@MatrixDescription, " + "@ProductGroup, " + "@ProductSubGroup, " + "@ClosingItemStatus, " + "@IsVatable, " + "@Remarks" + ");"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmClosingID = new MySqlParameter("@ClosingID", MySqlDbType.Int64); prmClosingID.Value = Details.ClosingID; cmd.Parameters.Add(prmClosingID); 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 prmInPercent = new MySqlParameter("@InPercent", MySqlDbType.Int16); prmInPercent.Value = Convert.ToInt16(Details.InPercent); cmd.Parameters.Add(prmInPercent); MySqlParameter prmTotalDiscount = new MySqlParameter("@TotalDiscount", MySqlDbType.Decimal); prmTotalDiscount.Value = Details.TotalDiscount; cmd.Parameters.Add(prmTotalDiscount); 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 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); MySqlParameter prmProductSubGroup = new MySqlParameter("@ProductSubGroup", MySqlDbType.String); prmProductSubGroup.Value = Details.ProductSubGroup; cmd.Parameters.Add(prmProductSubGroup); MySqlParameter prmClosingItemStatus = new MySqlParameter("@ClosingItemStatus", MySqlDbType.Int16); prmClosingItemStatus.Value = Details.ClosingItemStatus.ToString("d"); cmd.Parameters.Add(prmClosingItemStatus); MySqlParameter prmIsVatable = new MySqlParameter("@IsVatable", MySqlDbType.Int16); prmIsVatable.Value = Details.IsVatable; cmd.Parameters.Add(prmIsVatable); MySqlParameter prmRemarks = new MySqlParameter("@Remarks", MySqlDbType.String); prmRemarks.Value = Details.Remarks; cmd.Parameters.Add(prmRemarks); 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()); } Closing clsClosing = new Closing(base.Connection, base.Transaction); clsClosing.SynchronizeAmount(Details.ClosingID); return(iID); } catch (Exception ex) { throw base.ThrowException(ex); } }
public ClosingItemDetails Details(long ClosingItemID) { try { string SQL = "SELECT " + "ClosingItemID, " + "ClosingID, " + "ProductID, " + "ProductCode, " + "BarCode, " + "Description, " + "ProductUnitID, " + "ProductUnitCode, " + "Quantity, " + "UnitCost, " + "Discount, " + "InPercent, " + "TotalDiscount, " + "Amount, " + "VAT, " + "VatableAmount, " + "EVAT, " + "EVatableAmount, " + "LocalTax, " + "VariationMatrixID, " + "MatrixDescription, " + "ProductGroup, " + "ProductSubGroup, " + "ClosingItemStatus, " + "IsVatable, " + "Remarks " + "FROM tblClosingItems " + "WHERE ClosingItemID = @ClosingItemID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmClosingItemID = new MySqlParameter("@ClosingItemID", MySqlDbType.Int64); prmClosingItemID.Value = ClosingItemID; cmd.Parameters.Add(prmClosingItemID); MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult); ClosingItemDetails Details = new ClosingItemDetails(); while (myReader.Read()) { Details.ClosingItemID = ClosingItemID; Details.ClosingID = myReader.GetInt64("ClosingID"); Details.ProductID = myReader.GetInt64("ProductID"); Details.ProductCode = "" + myReader["ProductCode"].ToString(); Details.BarCode = "" + myReader["BarCode"].ToString(); Details.Description = "" + myReader["Description"].ToString(); Details.ProductUnitID = myReader.GetInt16("ProductUnitID"); Details.ProductUnitCode = "" + myReader["ProductUnitCode"].ToString(); Details.Quantity = myReader.GetDecimal("Quantity"); Details.UnitCost = myReader.GetDecimal("UnitCost"); Details.Discount = myReader.GetDecimal("Discount"); if (myReader["InPercent"].ToString() == "1") { Details.InPercent = true; } Details.TotalDiscount = myReader.GetDecimal("TotalDiscount"); Details.Amount = myReader.GetDecimal("Amount"); Details.VAT = myReader.GetDecimal("VAT"); Details.VatableAmount = myReader.GetDecimal("VatableAmount"); Details.EVAT = myReader.GetDecimal("EVAT"); Details.EVatableAmount = myReader.GetDecimal("EVatableAmount"); Details.LocalTax = myReader.GetDecimal("LocalTax"); Details.VariationMatrixID = myReader.GetInt64("VariationMatrixID"); Details.MatrixDescription = "" + myReader["MatrixDescription"].ToString(); Details.ProductGroup = "" + myReader["ProductGroup"].ToString(); Details.ProductSubGroup = "" + myReader["ProductSubGroup"].ToString(); Details.ClosingItemStatus = (ClosingItemStatus)Enum.Parse(typeof(ClosingItemStatus), myReader.GetString("ClosingItemStatus")); if (myReader["IsVatable"].ToString() == "1") { Details.IsVatable = true; } Details.Remarks = "" + myReader["Remarks"].ToString(); } myReader.Close(); return(Details); } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(ClosingItemDetails Details) { try { string SQL = "UPDATE tblClosingItems SET " + "ClosingID = @ClosingID, "+ "ProductID = @ProductID, "+ "ProductCode = @ProductCode, "+ "BarCode = @BarCode, "+ "Description = @Description, "+ "ProductUnitID = @ProductUnitID, "+ "ProductUnitCode = @ProductUnitCode, "+ "Quantity = @Quantity, "+ "UnitCost = @UnitCost, "+ "Discount = @Discount, "+ "InPercent = @InPercent, "+ "TotalDiscount = @TotalDiscount, "+ "Amount = @Amount, "+ "VAT = @VAT, "+ "VatableAmount = @VatableAmount, "+ "EVAT = @EVAT, "+ "EVatableAmount = @EVatableAmount, "+ "LocalTax = @LocalTax, "+ "VariationMatrixID = @VariationMatrixID, "+ "MatrixDescription = @MatrixDescription, "+ "ProductGroup = @ProductGroup, "+ "ProductSubGroup = @ProductSubGroup, "+ "ClosingItemStatus = @ClosingItemStatus, "+ "IsVatable = @IsVatable, "+ "Remarks = @Remarks "+ "WHERE ClosingItemID = @ClosingItemID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmClosingID = new MySqlParameter("@ClosingID", MySqlDbType.Int64); prmClosingID.Value = Details.ClosingID; cmd.Parameters.Add(prmClosingID); 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 prmInPercent = new MySqlParameter("@InPercent", MySqlDbType.Int16); prmInPercent.Value = Convert.ToInt16(Details.InPercent); cmd.Parameters.Add(prmInPercent); MySqlParameter prmTotalDiscount = new MySqlParameter("@TotalDiscount", MySqlDbType.Decimal); prmTotalDiscount.Value = Details.TotalDiscount; cmd.Parameters.Add(prmTotalDiscount); 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 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); MySqlParameter prmProductSubGroup = new MySqlParameter("@ProductSubGroup", MySqlDbType.String); prmProductSubGroup.Value = Details.ProductSubGroup; cmd.Parameters.Add(prmProductSubGroup); MySqlParameter prmClosingItemStatus = new MySqlParameter("@ClosingItemStatus", MySqlDbType.Int16); prmClosingItemStatus.Value = Details.ClosingItemStatus.ToString("d"); cmd.Parameters.Add(prmClosingItemStatus); MySqlParameter prmIsVatable = new MySqlParameter("@IsVatable", MySqlDbType.Int16); prmIsVatable.Value = Details.IsVatable; cmd.Parameters.Add(prmIsVatable); MySqlParameter prmRemarks = new MySqlParameter("@Remarks", MySqlDbType.String); prmRemarks.Value = Details.Remarks; cmd.Parameters.Add(prmRemarks); MySqlParameter prmClosingItemID = new MySqlParameter("@ClosingItemID", MySqlDbType.Int64); prmClosingItemID.Value = Details.ClosingItemID; cmd.Parameters.Add(prmClosingItemID); base.ExecuteNonQuery(cmd); Closing clsClosing = new Closing(base.Connection, base.Transaction); clsClosing.SynchronizeAmount(Details.ClosingID); } catch (Exception ex) { throw base.ThrowException(ex); } }