示例#1
0
        public TransferOutItemDetails Details(long TransferOutItemID)
        {
            try
            {
                string SQL = SQLSelect() + "WHERE TransferOutItemID = @TransferOutItemID;";

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

                MySqlParameter prmTransferOutItemID = new MySqlParameter("@TransferOutItemID", MySqlDbType.Int64);
                prmTransferOutItemID.Value = TransferOutItemID;
                cmd.Parameters.Add(prmTransferOutItemID);

                MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);

                TransferOutItemDetails Details = new TransferOutItemDetails();

                while (myReader.Read())
                {
                    Details.TransferOutItemID = TransferOutItemID;
                    Details.TransferOutID     = myReader.GetInt64("TransferOutID");
                    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.OriginalQuantity  = myReader.GetDecimal("OriginalQuantity");
                    Details.UnitCost          = myReader.GetDecimal("UnitCost");
                    Details.Discount          = myReader.GetDecimal("Discount");
                    Details.DiscountApplied   = myReader.GetDecimal("DiscountApplied");
                    Details.DiscountType      = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), myReader.GetString("DiscountType"));
                    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.isVATInclusive                = myReader.GetBoolean("isVATInclusive");
                    Details.VariationMatrixID             = myReader.GetInt64("VariationMatrixID");
                    Details.MatrixDescription             = "" + myReader["MatrixDescription"].ToString();
                    Details.ProductGroup                  = "" + myReader["ProductGroup"].ToString();
                    Details.ProductSubGroup               = "" + myReader["ProductSubGroup"].ToString();
                    Details.TransferOutItemStatus         = (TransferOutItemStatus)Enum.Parse(typeof(TransferOutItemStatus), myReader.GetString("TransferOutItemStatus"));
                    Details.TransferOutItemReceivedStatus = (TransferOutItemReceivedStatus)Enum.Parse(typeof(TransferOutItemReceivedStatus), myReader.GetString("TransferOutItemReceivedStatus"));
                    if (myReader["IsVatable"].ToString() == "1")
                    {
                        Details.IsVatable = true;
                    }
                    Details.Remarks = "" + myReader["Remarks"].ToString();

                    //Added April 28, 2010 4:20PM : For selling information
                    Details.SellingPrice    = myReader.GetDecimal("SellingPrice");
                    Details.SellingVAT      = myReader.GetDecimal("SellingVAT");
                    Details.SellingEVAT     = myReader.GetDecimal("SellingEVAT");
                    Details.SellingLocalTax = myReader.GetDecimal("SellingLocalTax");
                    Details.OldSellingPrice = myReader.GetDecimal("OldSellingPrice");
                }

                myReader.Close();

                return(Details);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
示例#2
0
        public long Insert(TransferOutItemDetails Details)
        {
            try
            {
                string SQL = "INSERT INTO tblTransferOutItems (" +
                             "TransferOutID, " +
                             "ProductID, " +
                             "ProductCode, " +
                             "BarCode, " +
                             "Description, " +
                             "ProductUnitID, " +
                             "ProductUnitCode, " +
                             "Quantity, " +
                             "OriginalQuantity, " +
                             "UnitCost, " +
                             "Discount, " +
                             "DiscountApplied, " +
                             "DiscountType, " +
                             "Amount, " +
                             "VAT, " +
                             "VatableAmount, " +
                             "EVAT, " +
                             "EVatableAmount, " +
                             "LocalTax, " +
                             "isVATInclusive, " +
                             "VariationMatrixID, " +
                             "MatrixDescription, " +
                             "ProductGroup, " +
                             "ProductSubGroup, " +
                             "TransferOutItemStatus, " +
                             "IsVatable, " +
                             "Remarks, " +
                             "ChartOfAccountIDTransferOut, " +
                             "ChartOfAccountIDTaxTransferOut, " +
                             "ChartOfAccountIDInventory," +
                             "SellingPrice," +
                             "SellingVAT," +
                             "SellingEVAT," +
                             "SellingLocalTax," +
                             "OldSellingPrice" +
                             ") VALUES (" +
                             "@TransferOutID, " +
                             "@ProductID, " +
                             "@ProductCode, " +
                             "@BarCode, " +
                             "@Description, " +
                             "@ProductUnitID, " +
                             "@ProductUnitCode, " +
                             "@Quantity, " +
                             "@Quantity, " +
                             "@UnitCost, " +
                             "@Discount, " +
                             "@DiscountApplied, " +
                             "@DiscountType, " +
                             "@Amount, " +
                             "@VAT, " +
                             "@VatableAmount, " +
                             "@EVAT, " +
                             "@EVatableAmount, " +
                             "@LocalTax, " +
                             "@isVATInclusive, " +
                             "@VariationMatrixID, " +
                             "@MatrixDescription, " +
                             "@ProductGroup, " +
                             "@ProductSubGroup, " +
                             "@TransferOutItemStatus, " +
                             "@IsVatable, " +
                             "@Remarks, " +
                             "(SELECT ChartOfAccountIDTransferOut FROM tblProducts WHERE ProductID = @ProductID), " +
                             "(SELECT ChartOfAccountIDTaxTransferOut FROM tblProducts WHERE ProductID = @ProductID), " +
                             "(SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID)," +
                             "@SellingPrice," +
                             "@SellingVAT," +
                             "@SellingEVAT," +
                             "@SellingLocalTax," +
                             "@OldSellingPrice" +
                             ");";

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

                MySqlParameter prmTransferOutID = new MySqlParameter("@TransferOutID", MySqlDbType.Int64);
                prmTransferOutID.Value = Details.TransferOutID;
                cmd.Parameters.Add(prmTransferOutID);

                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);

                MySqlParameter prmProductSubGroup = new MySqlParameter("@ProductSubGroup", MySqlDbType.String);
                prmProductSubGroup.Value = Details.ProductSubGroup;
                cmd.Parameters.Add(prmProductSubGroup);

                MySqlParameter prmTransferOutItemStatus = new MySqlParameter("@TransferOutItemStatus", MySqlDbType.Int16);
                prmTransferOutItemStatus.Value = Details.TransferOutItemStatus.ToString("d");
                cmd.Parameters.Add(prmTransferOutItemStatus);

                MySqlParameter prmIsVatable = new MySqlParameter("@IsVatable", MySqlDbType.Int16);
                prmIsVatable.Value = Convert.ToInt16(Details.IsVatable);
                cmd.Parameters.Add(prmIsVatable);

                MySqlParameter prmRemarks = new MySqlParameter("@Remarks", MySqlDbType.String);
                prmRemarks.Value = Details.Remarks;
                cmd.Parameters.Add(prmRemarks);

                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);

                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());
                }

                TransferOut clsTransferOut = new TransferOut(base.Connection, base.Transaction);
                clsTransferOut.SynchronizeAmount(Details.TransferOutID);

                return(iID);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
示例#3
0
        public long Insert(TransferOutItemDetails Details)
        {
            try
            {
                string SQL = "INSERT INTO tblTransferOutItems (" +
                                "TransferOutID, " +
                                "ProductID, " +
                                "ProductCode, " +
                                "BarCode, " +
                                "Description, " +
                                "ProductUnitID, " +
                                "ProductUnitCode, " +
                                "Quantity, " +
                                "OriginalQuantity, " +
                                "UnitCost, " +
                                "Discount, " +
                                "DiscountApplied, " +
                                "DiscountType, " +
                                "Amount, " +
                                "VAT, " +
                                "VatableAmount, " +
                                "EVAT, " +
                                "EVatableAmount, " +
                                "LocalTax, " +
                                "isVATInclusive, " +
                                "VariationMatrixID, " +
                                "MatrixDescription, " +
                                "ProductGroup, " +
                                "ProductSubGroup, " +
                                "TransferOutItemStatus, " +
                                "IsVatable, " +
                                "Remarks, " +
                                "ChartOfAccountIDTransferOut, " +
                                "ChartOfAccountIDTaxTransferOut, " +
                                "ChartOfAccountIDInventory," +
                                "SellingPrice," +
                                "SellingVAT," +
                                "SellingEVAT," +
                                "SellingLocalTax," +
                                "OldSellingPrice" +
                            ") VALUES (" +
                                "@TransferOutID, " +
                                "@ProductID, " +
                                "@ProductCode, " +
                                "@BarCode, " +
                                "@Description, " +
                                "@ProductUnitID, " +
                                "@ProductUnitCode, " +
                                "@Quantity, " +
                                "@Quantity, " +
                                "@UnitCost, " +
                                "@Discount, " +
                                "@DiscountApplied, " +
                                "@DiscountType, " +
                                "@Amount, " +
                                "@VAT, " +
                                "@VatableAmount, " +
                                "@EVAT, " +
                                "@EVatableAmount, " +
                                "@LocalTax, " +
                                "@isVATInclusive, " +
                                "@VariationMatrixID, " +
                                "@MatrixDescription, " +
                                "@ProductGroup, " +
                                "@ProductSubGroup, " +
                                "@TransferOutItemStatus, " +
                                "@IsVatable, " +
                                "@Remarks, " +
                                "(SELECT ChartOfAccountIDTransferOut FROM tblProducts WHERE ProductID = @ProductID), " +
                                "(SELECT ChartOfAccountIDTaxTransferOut FROM tblProducts WHERE ProductID = @ProductID), " +
                                "(SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID)," +
                                "@SellingPrice," +
                                "@SellingVAT," +
                                "@SellingEVAT," +
                                "@SellingLocalTax," +
                                "@OldSellingPrice" +
                            ");";

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

                MySqlParameter prmTransferOutID = new MySqlParameter("@TransferOutID",MySqlDbType.Int64);
                prmTransferOutID.Value = Details.TransferOutID;
                cmd.Parameters.Add(prmTransferOutID);

                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);

                MySqlParameter prmProductSubGroup = new MySqlParameter("@ProductSubGroup",MySqlDbType.String);
                prmProductSubGroup.Value = Details.ProductSubGroup;
                cmd.Parameters.Add(prmProductSubGroup);

                MySqlParameter prmTransferOutItemStatus = new MySqlParameter("@TransferOutItemStatus",MySqlDbType.Int16);
                prmTransferOutItemStatus.Value = Details.TransferOutItemStatus.ToString("d");
                cmd.Parameters.Add(prmTransferOutItemStatus);

                MySqlParameter prmIsVatable = new MySqlParameter("@IsVatable",MySqlDbType.Int16);
                prmIsVatable.Value = Convert.ToInt16(Details.IsVatable);
                cmd.Parameters.Add(prmIsVatable);

                MySqlParameter prmRemarks = new MySqlParameter("@Remarks",MySqlDbType.String);
                prmRemarks.Value = Details.Remarks;
                cmd.Parameters.Add(prmRemarks);

                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);

                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());
                }

                TransferOut clsTransferOut = new TransferOut(base.Connection, base.Transaction);
                clsTransferOut.SynchronizeAmount(Details.TransferOutID);

                return iID;
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
示例#4
0
        public void Update(TransferOutItemDetails Details)
        {
            try
            {
                string SQL = "UPDATE tblTransferOutItems SET " +
                             "TransferOutID					=	@TransferOutID, "+
                             "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, "+
                             "TransferOutItemStatus	=	@TransferOutItemStatus, "+
                             "IsVatable				=	@IsVatable, "+
                             "Remarks				=	@Remarks, "+
                             "ChartOfAccountIDTransferOut       = (SELECT ChartOfAccountIDTransferOut FROM tblProducts WHERE ProductID = @ProductID), " +
                             "ChartOfAccountIDTaxTransferOut    = (SELECT ChartOfAccountIDTaxTransferOut FROM tblProducts WHERE ProductID = @ProductID), " +
                             "ChartOfAccountIDInventory      = (SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID), " +
                             "SellingPrice			=	@SellingPrice, "+
                             "SellingVAT				=	@SellingVAT, "+
                             "SellingEVAT			=	@SellingEVAT, "+
                             "SellingLocalTax		=	@SellingLocalTax, "+
                             "OldSellingPrice		=	@OldSellingPrice "+
                             "WHERE TransferOutItemID = @TransferOutItemID;";

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

                MySqlParameter prmTransferOutID = new MySqlParameter("@TransferOutID", MySqlDbType.Int64);
                prmTransferOutID.Value = Details.TransferOutID;
                cmd.Parameters.Add(prmTransferOutID);

                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("@TransferOutItemStatus", Details.TransferOutItemStatus.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("@TransferOutItemID", Details.TransferOutItemID);

                base.ExecuteNonQuery(cmd);

                TransferOut clsTransferOut = new TransferOut(base.Connection, base.Transaction);
                clsTransferOut.SynchronizeAmount(Details.TransferOutID);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
示例#5
0
        public TransferOutItemDetails Details(long TransferOutItemID)
        {
            try
            {
                string SQL = SQLSelect() + "WHERE TransferOutItemID = @TransferOutItemID;";

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

                MySqlParameter prmTransferOutItemID = new MySqlParameter("@TransferOutItemID",MySqlDbType.Int64);
                prmTransferOutItemID.Value = TransferOutItemID;
                cmd.Parameters.Add(prmTransferOutItemID);

                MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);

                TransferOutItemDetails Details = new TransferOutItemDetails();

                while (myReader.Read())
                {
                    Details.TransferOutItemID = TransferOutItemID;
                    Details.TransferOutID = myReader.GetInt64("TransferOutID");
                    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.OriginalQuantity = myReader.GetDecimal("OriginalQuantity");
                    Details.UnitCost = myReader.GetDecimal("UnitCost");
                    Details.Discount = myReader.GetDecimal("Discount");
                    Details.DiscountApplied = myReader.GetDecimal("DiscountApplied");
                    Details.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), myReader.GetString("DiscountType"));
                    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.isVATInclusive = myReader.GetBoolean("isVATInclusive");
                    Details.VariationMatrixID = myReader.GetInt64("VariationMatrixID");
                    Details.MatrixDescription = "" + myReader["MatrixDescription"].ToString();
                    Details.ProductGroup = "" + myReader["ProductGroup"].ToString();
                    Details.ProductSubGroup = "" + myReader["ProductSubGroup"].ToString();
                    Details.TransferOutItemStatus = (TransferOutItemStatus)Enum.Parse(typeof(TransferOutItemStatus), myReader.GetString("TransferOutItemStatus"));
                    Details.TransferOutItemReceivedStatus = (TransferOutItemReceivedStatus)Enum.Parse(typeof(TransferOutItemReceivedStatus), myReader.GetString("TransferOutItemReceivedStatus"));
                    if (myReader["IsVatable"].ToString() == "1")
                        Details.IsVatable = true;
                    Details.Remarks = "" + myReader["Remarks"].ToString();

                    //Added April 28, 2010 4:20PM : For selling information
                    Details.SellingPrice = myReader.GetDecimal("SellingPrice");
                    Details.SellingVAT = myReader.GetDecimal("SellingVAT");
                    Details.SellingEVAT = myReader.GetDecimal("SellingEVAT");
                    Details.SellingLocalTax = myReader.GetDecimal("SellingLocalTax");
                    Details.OldSellingPrice = myReader.GetDecimal("OldSellingPrice");
                }

                myReader.Close();

                return Details;
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
示例#6
0
        public void Update(TransferOutItemDetails Details)
        {
            try
            {
                string SQL = "UPDATE tblTransferOutItems SET " +
                                "TransferOutID					=	@TransferOutID, " +
                                "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, " +
                                "TransferOutItemStatus	=	@TransferOutItemStatus, " +
                                "IsVatable				=	@IsVatable, " +
                                "Remarks				=	@Remarks, " +
                                "ChartOfAccountIDTransferOut       = (SELECT ChartOfAccountIDTransferOut FROM tblProducts WHERE ProductID = @ProductID), " +
                                "ChartOfAccountIDTaxTransferOut    = (SELECT ChartOfAccountIDTaxTransferOut FROM tblProducts WHERE ProductID = @ProductID), " +
                                "ChartOfAccountIDInventory      = (SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID), " +
                                "SellingPrice			=	@SellingPrice, " +
                                "SellingVAT				=	@SellingVAT, " +
                                "SellingEVAT			=	@SellingEVAT, " +
                                "SellingLocalTax		=	@SellingLocalTax, " +
                                "OldSellingPrice		=	@OldSellingPrice " +
                            "WHERE TransferOutItemID = @TransferOutItemID;";

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

                MySqlParameter prmTransferOutID = new MySqlParameter("@TransferOutID",MySqlDbType.Int64);
                prmTransferOutID.Value = Details.TransferOutID;
                cmd.Parameters.Add(prmTransferOutID);

                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("@TransferOutItemStatus", Details.TransferOutItemStatus.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("@TransferOutItemID", Details.TransferOutItemID);

                base.ExecuteNonQuery(cmd);

                TransferOut clsTransferOut = new TransferOut(base.Connection, base.Transaction);
                clsTransferOut.SynchronizeAmount(Details.TransferOutID);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
示例#7
0
        private void SaveRecord()
        {
            TransferOutItemDetails clsDetails = new TransferOutItemDetails();

            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.TransferOutID = Convert.ToInt64(lblTransferOutID.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);

            TransferOutItem clsTransferOutItem = new TransferOutItem();
            if (lblTransferOutItemID.Text != "0")
            {
                clsDetails.TransferOutItemID = Convert.ToInt64(lblTransferOutItemID.Text);
                clsTransferOutItem.Update(clsDetails);
            }
            else
                clsTransferOutItem.Insert(clsDetails);

            TransferOutDetails clsTransferOutDetails = new TransferOutDetails();
            clsTransferOutDetails.TransferOutID = clsDetails.TransferOutID;
            clsTransferOutDetails.DiscountApplied = Convert.ToDecimal(txtTransferOutDiscountApplied.Text);
            clsTransferOutDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboTransferOutDiscountType.SelectedItem.Value);

            clsTransferOutDetails.Discount2Applied = Convert.ToDecimal(txtTransferOutDiscount2Applied.Text);
            clsTransferOutDetails.Discount2Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboTransferOutDiscount2Type.SelectedItem.Value);

            clsTransferOutDetails.Discount3Applied = Convert.ToDecimal(txtTransferOutDiscount3Applied.Text);
            clsTransferOutDetails.Discount3Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboTransferOutDiscount3Type.SelectedItem.Value);

            TransferOut clsTransferOut = new TransferOut(clsTransferOutItem.Connection, clsTransferOutItem.Transaction);
            clsTransferOut.UpdateDiscount(clsDetails.TransferOutID, clsTransferOutDetails.DiscountApplied, clsTransferOutDetails.DiscountType, clsTransferOutDetails.Discount2Applied, clsTransferOutDetails.Discount2Type, clsTransferOutDetails.Discount3Applied, clsTransferOutDetails.Discount3Type);

            clsTransferOutDetails = clsTransferOut.Details(clsDetails.TransferOutID);
            clsTransferOutItem.CommitAndDispose();

            UpdateFooter(clsTransferOutDetails);
        }
示例#8
0
        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 Transfer In 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;

                TransferOut clsTransferOut = new TransferOut();
                clsTransferOut.GetConnection();
                TransferOutDetails clsTransferOutDetails = new TransferOutDetails();

                TransferOutItem clsTransferOutItem = new TransferOutItem(clsTransferOut.Connection, clsTransferOut.Transaction);
                TransferOutItemDetails clsTransferOutItemDetails;

                Contacts clsContact = new Contacts(clsTransferOut.Connection, clsTransferOut.Transaction);
                ContactDetails clsContactDetails;

                ContactGroups clsContactGroup = new ContactGroups(clsTransferOut.Connection, clsTransferOut.Transaction);
                ContactGroupDetails clsContactGroupDetails;

                Data.Unit clsUnit = new Data.Unit(clsTransferOut.Connection, clsTransferOut.Transaction);
                UnitDetails clsUnitDetails;

                ProductGroup clsProductGroup = new Data.ProductGroup(clsTransferOut.Connection, clsTransferOut.Transaction);
                ProductGroupDetails clsProductGroupDetails;

                ProductSubGroup clsProductSubGroup = new Data.ProductSubGroup(clsTransferOut.Connection, clsTransferOut.Transaction);
                ProductSubGroupDetails clsProductSubGroupDetails;

                Products clsProduct = new Products(clsTransferOut.Connection, clsTransferOut.Transaction);
                ProductDetails clsProductDetails;

                ProductVariations clsProductVariation = new ProductVariations(clsTransferOut.Connection, clsTransferOut.Transaction);
                ProductVariationDetails clsProductVariationDetails;

                Branch clsBranch = new Branch(clsTransferOut.Connection, clsTransferOut.Transaction);
                BranchDetails clsBranchDetails;

                long lngProductID = 0; long lngProductCtr = 0;

                while (xmlReader.Read())
                {
                    switch (xmlReader.NodeType)
                    {
                        case XmlNodeType.Element:

                            if (xmlReader.Name == "TransferOutDetails")
                            {
                                clsTransferOutDetails.TransferOutNo = lnkTransferOutNo.Text;
                                clsTransferOutDetails.TransferOutDate = DateTime.Parse(lblTransferOutDate.Text);

                                clsTransferOutDetails.SupplierCode = xmlReader.GetAttribute("SupplierCode").ToString();
                                clsTransferOutDetails.SupplierContact = xmlReader.GetAttribute("SupplierContact").ToString();
                                clsTransferOutDetails.SupplierAddress = xmlReader.GetAttribute("SupplierAddress").ToString();
                                clsTransferOutDetails.SupplierTelephoneNo = xmlReader.GetAttribute("SupplierTelephoneNo").ToString();
                                clsTransferOutDetails.SupplierModeOfTerms = int.Parse(xmlReader.GetAttribute("SupplierModeOfTerms").ToString());
                                clsTransferOutDetails.SupplierTerms = int.Parse(xmlReader.GetAttribute("SupplierTerms").ToString());
                                clsTransferOutDetails.SupplierID = clsContact.Details(xmlReader.GetAttribute("SupplierCode").ToString()).ContactID;
                                if (clsTransferOutDetails.SupplierID == 0)
                                {
                                    clsContactDetails = new ContactDetails();
                                    clsContactDetails.ContactCode = clsTransferOutDetails.SupplierCode;
                                    clsContactDetails.ContactName = xmlReader.GetAttribute("SupplierName").ToString();
                                    clsContactDetails.BusinessName = clsTransferOutDetails.SupplierContact;
                                    clsContactDetails.Address = clsTransferOutDetails.SupplierAddress;
                                    clsContactDetails.TelephoneNo = clsTransferOutDetails.SupplierTelephoneNo;
                                    clsContactDetails.ModeOfTerms = (ModeOfTerms)Enum.Parse(typeof(ModeOfTerms), clsTransferOutDetails.SupplierModeOfTerms.ToString());
                                    clsContactDetails.Terms = clsTransferOutDetails.SupplierTerms;
                                    clsContactDetails.Remarks = "Added in from Imported TransferOut #";
                                    clsContactDetails.ContactGroupID = int.Parse(Contacts.DEFAULT_SUPPLIER_ID.ToString("d"));
                                    clsContactDetails.DateCreated = DateTime.Now;
                                    clsTransferOutDetails.SupplierID = clsContact.Insert(clsContactDetails);
                                }
                                clsTransferOutDetails.RequiredDeliveryDate = DateTime.Parse(xmlReader.GetAttribute("RequiredDeliveryDate").ToString());
                                clsTransferOutDetails.BranchID = clsBranch.Details(xmlReader.GetAttribute("BranchCode")).BranchID;
                                if (clsTransferOutDetails.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");
                                    clsTransferOutDetails.BranchID = clsBranch.Insert(clsBranchDetails);
                                }

                                clsTransferOutDetails.TransferrerID = long.Parse(xmlReader.GetAttribute("TransferrerID"));
                                clsTransferOutDetails.TransferrerName = xmlReader.GetAttribute("TransferrerName");

                                clsTransferOutDetails.SubTotal = decimal.Parse(xmlReader.GetAttribute("SubTotal"));
                                clsTransferOutDetails.Discount = decimal.Parse(xmlReader.GetAttribute("Discount"));
                                clsTransferOutDetails.DiscountApplied = decimal.Parse(xmlReader.GetAttribute("DiscountApplied"));
                                clsTransferOutDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), xmlReader.GetAttribute("DiscountType"));
                                clsTransferOutDetails.VAT = decimal.Parse(xmlReader.GetAttribute("VAT"));
                                clsTransferOutDetails.VatableAmount = decimal.Parse(xmlReader.GetAttribute("VatableAmount"));
                                clsTransferOutDetails.EVAT = decimal.Parse(xmlReader.GetAttribute("EVAT"));
                                clsTransferOutDetails.EVatableAmount = decimal.Parse(xmlReader.GetAttribute("EVatableAmount"));
                                clsTransferOutDetails.LocalTax = decimal.Parse(xmlReader.GetAttribute("LocalTax"));
                                clsTransferOutDetails.Freight = decimal.Parse(xmlReader.GetAttribute("Freight"));
                                clsTransferOutDetails.Deposit = decimal.Parse(xmlReader.GetAttribute("Deposit"));
                                clsTransferOutDetails.UnpaidAmount = decimal.Parse(xmlReader.GetAttribute("UnpaidAmount"));
                                clsTransferOutDetails.PaidAmount = decimal.Parse(xmlReader.GetAttribute("PaidAmount"));
                                clsTransferOutDetails.TotalItemDiscount = decimal.Parse(xmlReader.GetAttribute("TotalItemDiscount"));
                                clsTransferOutDetails.Status = (TransferOutStatus)Enum.Parse(typeof(TransferOutStatus), xmlReader.GetAttribute("Status"));
                                clsTransferOutDetails.Remarks = xmlReader.GetAttribute("Remarks");
                                clsTransferOutDetails.SupplierDRNo = xmlReader.GetAttribute("SupplierDRNo");
                                clsTransferOutDetails.DeliveryDate = DateTime.Parse(xmlReader.GetAttribute("DeliveryDate"));
                                clsTransferOutDetails.CancelledDate = DateTime.Parse(xmlReader.GetAttribute("CancelledDate"));
                                clsTransferOutDetails.Remarks = xmlReader.GetAttribute("Remarks");
                                clsTransferOutDetails.CancelledRemarks = xmlReader.GetAttribute("CancelledRemarks");
                                clsTransferOutDetails.CancelledByID = long.Parse(xmlReader.GetAttribute("CancelledByID"));

                                clsTransferOut.Update(clsTransferOutDetails);

                            }
                            else if (xmlReader.Name == "TransferOutItem")
                            {
                                clsTransferOutItemDetails = new TransferOutItemDetails();
                                clsTransferOutItemDetails.TransferOutID = long.Parse(lblTransferOutID.Text);

                                clsTransferOutItemDetails.ProductCode = xmlReader.GetAttribute("ProductCode");
                                clsTransferOutItemDetails.BarCode = xmlReader.GetAttribute("BarCode");
                                clsTransferOutItemDetails.Description = xmlReader.GetAttribute("ProductDesc");
                                clsTransferOutItemDetails.ProductSubGroup = xmlReader.GetAttribute("ItemProductSubGroup");
                                clsTransferOutItemDetails.ProductGroup = xmlReader.GetAttribute("ItemProductGroup");
                                clsTransferOutItemDetails.ProductUnitID = Convert.ToInt32(xmlReader.GetAttribute("ItemProductUnitID"));
                                clsTransferOutItemDetails.ProductUnitCode = xmlReader.GetAttribute("ItemProductUnitCode");
                                clsTransferOutItemDetails.Quantity = Convert.ToDecimal(xmlReader.GetAttribute("ItemQuantity"));
                                clsTransferOutItemDetails.UnitCost = Convert.ToDecimal(xmlReader.GetAttribute("ItemUnitCost"));
                                clsTransferOutItemDetails.Discount = Convert.ToDecimal(xmlReader.GetAttribute("ItemDiscount"));
                                clsTransferOutItemDetails.DiscountApplied = Convert.ToDecimal(xmlReader.GetAttribute("ItemDiscountApplied"));
                                clsTransferOutItemDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), xmlReader.GetAttribute("ItemDiscountType"));
                                clsTransferOutItemDetails.Amount = Convert.ToDecimal(xmlReader.GetAttribute("ItemAmount"));
                                clsTransferOutItemDetails.IsVatable = Convert.ToBoolean(Convert.ToInt16(xmlReader.GetAttribute("ItemIsVatable")));
                                clsTransferOutItemDetails.VatableAmount = Convert.ToDecimal(xmlReader.GetAttribute("ItemVatableAmount"));
                                clsTransferOutItemDetails.EVatableAmount = Convert.ToDecimal(xmlReader.GetAttribute("ItemEVatableAmount"));
                                clsTransferOutItemDetails.LocalTax = Convert.ToDecimal(xmlReader.GetAttribute("ItemLocalTax"));
                                clsTransferOutItemDetails.VAT = Convert.ToDecimal(xmlReader.GetAttribute("ItemVAT"));
                                clsTransferOutItemDetails.EVAT = Convert.ToDecimal(xmlReader.GetAttribute("ItemEVAT"));
                                clsTransferOutItemDetails.LocalTax = Convert.ToDecimal(xmlReader.GetAttribute("ItemLocalTax"));
                                clsTransferOutItemDetails.isVATInclusive = Convert.ToBoolean(Convert.ToInt16(xmlReader.GetAttribute("ItemisVATInclusive")));
                                clsTransferOutItemDetails.IsVatable = Convert.ToBoolean(Convert.ToInt16(xmlReader.GetAttribute("ItemIsVatable")));
                                clsTransferOutItemDetails.TransferOutItemStatus = (TransferOutItemStatus)Enum.Parse(typeof(TransferOutItemStatus), xmlReader.GetAttribute("ItemTransferOutItemStatus"));
                                clsTransferOutItemDetails.VariationMatrixID = Convert.ToInt64(xmlReader.GetAttribute("ItemVariationMatrixID"));
                                clsTransferOutItemDetails.MatrixDescription = xmlReader.GetAttribute("ItemBaseVariationDescription");
                                clsTransferOutItemDetails.ProductGroup = xmlReader.GetAttribute("ProductGroup");
                                clsTransferOutItemDetails.ProductSubGroup = xmlReader.GetAttribute("ProductSubGroup");
                                clsTransferOutItemDetails.Remarks = xmlReader.GetAttribute("ItemRemarks");
                                clsTransferOutItemDetails.SellingPrice = Convert.ToDecimal(xmlReader.GetAttribute("ItemSellingPrice"));
                                clsTransferOutItemDetails.SellingVAT = Convert.ToDecimal(xmlReader.GetAttribute("ItemSellingVAT"));
                                clsTransferOutItemDetails.SellingEVAT = Convert.ToDecimal(xmlReader.GetAttribute("ItemSellingEVAT"));
                                clsTransferOutItemDetails.SellingLocalTax = Convert.ToDecimal(xmlReader.GetAttribute("ItemSellingLocalTax"));
                                clsTransferOutItemDetails.OldSellingPrice = Convert.ToDecimal(xmlReader.GetAttribute("ItemOldSellingPrice"));

                                clsTransferOutItemDetails.ProductID = clsProduct.Details(clsTransferOutItemDetails.BarCode).ProductID;
                                lngProductID = clsTransferOutItemDetails.ProductID;
                                if (clsTransferOutItemDetails.ProductID == 0)
                                {
                                    clsTransferOutItemDetails.ProductID = clsProduct.Details(clsTransferOutItemDetails.ProductCode).ProductID;
                                    if (clsTransferOutItemDetails.ProductID == 0)
                                    {
                                        //insert new product
                                        clsProductDetails = new ProductDetails();
                                        clsProductDetails.BarCode = clsTransferOutItemDetails.BarCode;
                                        clsProductDetails.ProductCode = clsTransferOutItemDetails.ProductCode;
                                        clsProductDetails.ProductDesc = clsTransferOutItemDetails.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 = clsTransferOutDetails.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 = clsTransferOutDetails.SupplierCode;
                                            clsContactDetails.ContactName = clsTransferOutDetails.SupplierContact;

                                            clsContactDetails.ModeOfTerms = (ModeOfTerms)Enum.Parse(typeof(ModeOfTerms), clsTransferOutDetails.SupplierModeOfTerms.ToString());
                                            clsContactDetails.Terms = clsTransferOutDetails.SupplierTerms;
                                            clsContactDetails.Address = clsTransferOutDetails.SupplierAddress;
                                            clsContactDetails.BusinessName = clsTransferOutDetails.SupplierContact;
                                            clsContactDetails.TelephoneNo = clsTransferOutDetails.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);
                                        }

                                        clsTransferOutItemDetails.ProductID = clsProduct.Insert(clsProductDetails);
                                    }
                                    else
                                    {
                                        //product code already exist but not the same barcode
                                        clsProduct.UpdateBarcode(clsTransferOutItemDetails.ProductID, clsTransferOutItemDetails.BarCode);
                                    }
                                    lngProductID = clsTransferOutItemDetails.ProductID;
                                }

                                clsTransferOutItem.Insert(clsTransferOutItemDetails);

                                clsTransferOutDetails = new TransferOutDetails();
                                clsTransferOutDetails.TransferOutID = clsTransferOutItemDetails.TransferOutID;
                                clsTransferOutDetails.DiscountApplied = Convert.ToDecimal(txtTransferOutDiscountApplied.Text);
                                clsTransferOutDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboTransferOutDiscountType.SelectedItem.Value);

                                clsTransferOutDetails.Discount2Applied = Convert.ToDecimal(txtTransferOutDiscount2Applied.Text);
                                clsTransferOutDetails.Discount2Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboTransferOutDiscount2Type.SelectedItem.Value);

                                clsTransferOutDetails.Discount3Applied = Convert.ToDecimal(txtTransferOutDiscount2Applied.Text);
                                clsTransferOutDetails.Discount3Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboTransferOutDiscount3Type.SelectedItem.Value);

                                clsTransferOut = new TransferOut(clsTransferOutItem.Connection, clsTransferOutItem.Transaction);
                                clsTransferOut.UpdateDiscount(clsTransferOutItemDetails.TransferOutID, clsTransferOutDetails.DiscountApplied, clsTransferOutDetails.DiscountType, clsTransferOutDetails.Discount2Applied, clsTransferOutDetails.Discount2Type, clsTransferOutDetails.Discount3Applied, clsTransferOutDetails.Discount3Type);

                                clsTransferOutDetails = clsTransferOut.Details(clsTransferOutItemDetails.TransferOutID);
                                UpdateFooter(clsTransferOutDetails);

                                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();

                clsTransferOut.CommitAndDispose();
                LoadRecord();
                LoadItems();
            }
            else
            {
                string stScript = "<Script>";
                stScript += "window.alert('Please select Transfer In file to upload.')";
                stScript += "</Script>";
                Response.Write(stScript);
            }
        }
示例#9
0
        public void GenerateItemsForReorder(Int32 TerminalID, long TransferOutID)
        {
            try
            {
                GetConnection();

                Terminal clsTerminal = new Terminal(base.Connection, base.Transaction);
                TerminalDetails clsTerminalDetails = clsTerminal.Details(TerminalID);

                TransferOutDetails clsTransferOutDetails = Details(TransferOutID);

                Products clsProduct = new Products(base.Connection, base.Transaction);
                System.Data.DataTable dt = clsProduct.ForReorder(clsTransferOutDetails.SupplierID);

                TransferOutItem clsTransferOutItem = new TransferOutItem(base.Connection, base.Transaction);
                ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    TransferOutItemDetails clsDetails = new TransferOutItemDetails();

                    clsDetails.TransferOutID = TransferOutID;
                    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"]);
                    clsDetails.ProductUnitCode = dr["UnitName"].ToString();
                    clsDetails.Quantity = Convert.ToDecimal(dr["ReorderQty"]);
                    clsDetails.UnitCost = Convert.ToDecimal(dr["Price"]);
                    clsDetails.Discount = 0;
                    clsDetails.DiscountApplied = 0;
                    clsDetails.DiscountType = DiscountTypes.Percentage;
                    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, clsTransferOutDetails.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();
                            clsTransferOutItem.Insert(clsDetails);
                        }
                    else
                    {
                        clsDetails.VariationMatrixID = 0;
                        clsDetails.MatrixDescription = string.Empty;
                        clsTransferOutItem.Insert(clsDetails);
                    }

                }
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }