Ejemplo n.º 1
0
        private void AddItemToInventory(long CreditMemoID)
        {
            CreditMemoDetails clsCreditMemoDetails = Details(CreditMemoID);
            ERPConfig         clsERPConfig         = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails  clsERPConfigDetails  = clsERPConfig.Details();

            CreditMemoItems         clsCreditMemoItems         = new CreditMemoItems(base.Connection, base.Transaction);
            ProductUnit             clsProductUnit             = new ProductUnit(base.Connection, base.Transaction);
            Products                clsProduct                 = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsCreditMemoItems.ListAsDataTable(CreditMemoID);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID     = long.Parse(dr["ProductID"].ToString());
                int  intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity     = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long    lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string  strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string  strProductCode       = "" + dr["ProductCode"].ToString();
                decimal decUnitCost          = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost          = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                /*******************************************
                 * Do not Add to Inventory coz this is a Debit Memo and no effect on inventory
                 * ****************************************/

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                InventoryDetails clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom   = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo     = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate       = clsCreditMemoDetails.PostingDate;
                clsInventoryDetails.ReferenceNo       = clsCreditMemoDetails.CNNo;
                clsInventoryDetails.ContactID         = clsCreditMemoDetails.CustomerID;
                clsInventoryDetails.ContactCode       = clsCreditMemoDetails.CustomerCode;
                clsInventoryDetails.ProductID         = lngProductID;
                clsInventoryDetails.ProductCode       = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.SCreditQuantity   = decQuantity;
                clsInventoryDetails.SCreditCost       = decItemCost - decVAT;
                clsInventoryDetails.SCreditVAT        = decItemCost; //Sales Return with VAT

                clsInventory.Insert(clsInventoryDetails);
            }
            //myReader.Close();
        }
Ejemplo n.º 2
0
		private void LoadRecord()
		{
			ERPConfig clsERPConfig = new ERPConfig();
			ERPConfigDetails clsDetails = clsERPConfig.Details();

			clsERPConfig.CommitAndDispose();

			txtDateFrom.Text = clsDetails.PostingDateFrom.ToString("yyyy-MM-dd");
			txtDateTo.Text = clsDetails.PostingDateTo.ToString("yyyy-MM-dd");
		}
Ejemplo n.º 3
0
		private void SaveRecord()
		{
			
			ERPConfigDetails clsDetails = new ERPConfigDetails();

			clsDetails.PostingDateFrom = Convert.ToDateTime(txtDateFrom.Text);
			clsDetails.PostingDateTo = Convert.ToDateTime(txtDateTo.Text);

			ERPConfig clsERPConfig = new ERPConfig();
			clsERPConfig.UpdatePostingDate(clsDetails.PostingDateFrom, clsDetails.PostingDateTo);

			clsERPConfig.CommitAndDispose();
		}
Ejemplo n.º 4
0
		private void LoadRecord()
		{
			ERPConfig clsERPConfig = new ERPConfig();
			APLinkConfigDetails clsDetails = clsERPConfig.APLinkDetails();

			clsERPConfig.CommitAndDispose();

            cboChartOfAccountAPTracking.SelectedIndex = cboChartOfAccountAPTracking.Items.IndexOf(cboChartOfAccountAPTracking.Items.FindByValue(clsDetails.ChartOfAccountIDAPTracking.ToString()));
            cboChartOfAccountAPBills.SelectedIndex = cboChartOfAccountAPBills.Items.IndexOf(cboChartOfAccountAPBills.Items.FindByValue(clsDetails.ChartOfAccountIDAPBills.ToString()));
            cboChartOfAccountAPFreight.SelectedIndex = cboChartOfAccountAPFreight.Items.IndexOf(cboChartOfAccountAPFreight.Items.FindByValue(clsDetails.ChartOfAccountIDAPFreight.ToString()));
            cboChartOfAccountAPVDeposit.SelectedIndex = cboChartOfAccountAPVDeposit.Items.IndexOf(cboChartOfAccountAPVDeposit.Items.FindByValue(clsDetails.ChartOfAccountIDAPVDeposit.ToString()));
            cboChartOfAccountAPContra.SelectedIndex = cboChartOfAccountAPContra.Items.IndexOf(cboChartOfAccountAPContra.Items.FindByValue(clsDetails.ChartOfAccountIDAPContra.ToString()));
            cboChartOfAccountAPLatePayment.SelectedIndex = cboChartOfAccountAPLatePayment.Items.IndexOf(cboChartOfAccountAPLatePayment.Items.FindByValue(clsDetails.ChartOfAccountIDAPLatePayment.ToString()));

		}
Ejemplo n.º 5
0
        public string LastTransactionNo()
        {
            try
            {
                string stRetValue = String.Empty;

                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                stRetValue = clsERPConfig.get_LastWBranchTransferNo();

                return(stRetValue);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 6
0
		private void AddItemToInventory(long POID)
		{

			PODetails clsPODetails = Details(POID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			POItem clsPOItem = new POItem(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);

			Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
            InventoryDetails clsInventoryDetails;

            ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

			//MySqlDataReader myReader = clsPOItem.List(POID, "POItemID", SortOption.Ascending);
            System.Data.DataTable dt = clsPOItem.ListAsDataTable(POID, "POItemID", SortOption.Ascending);

			//while (myReader.Read())
            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = Convert.ToInt64(dr["ProductID"]);
                int intProductUnitID = Convert.ToInt16(dr["ProductUnitID"]);

                decimal decItemQuantity = Convert.ToDecimal(dr["Quantity"]);
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]);
                string strMatrixDescription = dr["MatrixDescription"].ToString();
                string strProductCode = dr["ProductCode"].ToString();
                string strProductUnitCode = dr["ProductUnitCode"].ToString();
                decimal decUnitCost = Convert.ToDecimal(dr["UnitCost"]);
                decimal decItemCost = Convert.ToDecimal(dr["Amount"]);
                decimal decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                /*******************************************
				 * Add in the Price History
				 * ****************************************/
                // Update ProductPackagePriceHistory first to get the history
                clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                clsProductPackagePriceHistoryDetails.UID = clsPODetails.PurchaserID;
                clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                clsProductPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                clsProductPackagePriceHistoryDetails.Price = decSellingPrice;
                clsProductPackagePriceHistoryDetails.VAT = decVAT;
                clsProductPackagePriceHistoryDetails.EVAT = decEVAT;
                clsProductPackagePriceHistoryDetails.LocalTax = decLocalTax;
                clsProductPackagePriceHistoryDetails.Remarks = "Based on PO #: " + clsPODetails.PONo;
                ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);


				/*******************************************
				 * Add to Inventory
				 * ****************************************/
                //clsProduct.AddQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0) { clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity); }
                // July 26, 2011: change the above codes to the following
                clsProduct.AddQuantity(clsPODetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_PURCHASE) + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsPODetails.PONo, clsPODetails.PurchaserName);

                /*******************************************
				 * Update Purchasing Information
                 * 
                 * 30May2013 Include variation in the package.
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, iBaseUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                }
                clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, decUnitCost);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.BranchID = clsPODetails.BranchID;
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsPODetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsPODetails.PONo;
				clsInventoryDetails.ContactID = clsPODetails.SupplierID;
				clsInventoryDetails.ContactCode = clsPODetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.PurchaseQuantity = decQuantity;
                clsInventoryDetails.PurchaseCost = decItemCost - decVAT;
                clsInventoryDetails.PurchaseVAT = decItemCost;	// Purchase Cost with VAT

				clsInventory.Insert(clsInventoryDetails);

                /*******************************************
				 * Added Jan 1, 2010 4:20PM
                 * Update Selling Information when PO is posted
				 * ****************************************/
                clsProduct.UpdateSellingPrice(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, Convert.ToDecimal(dr["SellingPrice"]), -1, -1, -1, -1, -1);

                /*******************************************
				 * Added Mar 8, 2010 4:20PM
                 * Update the purchase price history to check who has the lowest price.
				 * ****************************************/
                ProductPurchasePriceHistoryDetails clsProductPurchasePriceHistoryDetails = new ProductPurchasePriceHistoryDetails();
                clsProductPurchasePriceHistoryDetails.ProductID = lngProductID;
                clsProductPurchasePriceHistoryDetails.MatrixID = lngVariationMatrixID;
                clsProductPurchasePriceHistoryDetails.SupplierID = clsPODetails.SupplierID;
                clsProductPurchasePriceHistoryDetails.PurchasePrice = decUnitCost;
                clsProductPurchasePriceHistoryDetails.PurchaseDate = clsPODetails.PODate;
                clsProductPurchasePriceHistoryDetails.Remarks = clsPODetails.PONo;
                clsProductPurchasePriceHistoryDetails.PurchaserName = clsPODetails.PurchaserName;
                ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(base.Connection, base.Transaction);
                clsProductPurchasePriceHistory.AddToList(clsProductPurchasePriceHistoryDetails);
			}
			//myReader.Close();

		}
Ejemplo n.º 7
0
		private void AddItemToInventory(long WBranchTransferID)
		{

			WBranchTransferDetails clsWBranchTransferDetails = Details(WBranchTransferID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			WBranchTransferItem clsWBranchTransferItem = new WBranchTransferItem(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
            InventoryDetails clsInventoryDetails;

			System.Data.DataTable dt = clsWBranchTransferItem.ListAsDataTable(WBranchTransferID, "WBranchTransferItemID", SortOption.Ascending);

            foreach (System.Data.DataRow dr in dt.Rows)
			{
				long lngProductID = Int64.Parse(dr["ProductID"].ToString());
				int intProductUnitID = Int16.Parse(dr["ProductUnitID"].ToString());

				decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);
				
				long lngVariationMatrixID = Int64.Parse(dr["VariationMatrixID"].ToString());
				string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
				string strProductCode = "" + dr["ProductCode"].ToString();
                string strProductUnitCode = "" + dr["ProductUnitCode"].ToString();
				decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
				decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

				/*******************************************
				 * Subtract BranchIDFrom then Add to BranchIDTo -- Inventory
				 * ****************************************/
                clsProduct.SubtractQuantity(clsWBranchTransferDetails.BranchIDFrom, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_BRANCH_TRANSFER_FROM) + " " + clsWBranchTransferDetails.BranchCodeFrom + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsWBranchTransferDetails.WBranchTransferNo, clsWBranchTransferDetails.TransferrerName);
                clsProduct.AddQuantity(clsWBranchTransferDetails.BranchIDTo, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_BRANCH_TRANSFER_TO) + " " + clsWBranchTransferDetails.BranchCodeTo + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsWBranchTransferDetails.WBranchTransferNo, clsWBranchTransferDetails.TransferrerName);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsWBranchTransferDetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsWBranchTransferDetails.WBranchTransferNo;
				clsInventoryDetails.ContactID = Constants.C_RETAILPLUS_SUPPLIERID;
                clsInventoryDetails.ContactCode = Constants.C_RETAILPLUS_SUPPLIER;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
				
                clsInventoryDetails.PurchaseCost = decItemCost - decVAT;
                clsInventoryDetails.PurchaseVAT = decItemCost;	// Purchase Cost with VAT

                // insert into branchid from with minus quantity
                clsInventoryDetails.BranchID = clsWBranchTransferDetails.BranchIDFrom;
                clsInventoryDetails.PurchaseQuantity = -decQuantity;
                clsInventory.Insert(clsInventoryDetails);

                // insert into branchid to with add quantity
                clsInventoryDetails.BranchID = clsWBranchTransferDetails.BranchIDTo;
                clsInventoryDetails.PurchaseQuantity = decQuantity;
                clsInventory.Insert(clsInventoryDetails);
			}
		}
Ejemplo n.º 8
0
        private void SubtractItemFromInventory(long TransferOutID)
        {

            TransferOutDetails clsTransferOutDetails = Details(TransferOutID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            TransferOutItem clsTransferOutItem = new TransferOutItem(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
            MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
            InventoryDetails clsInventoryDetails;

            //MatrixPackagePriceHistoryDetails clsMatrixPackagePriceHistoryDetails;
            //ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

            System.Data.DataTable dt = clsTransferOutItem.ListAsDataTable(TransferOutID, "TransferOutItemID", SortOption.Ascending);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID = long.Parse(dr["ProductID"].ToString());
                int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string strProductCode = "" + dr["ProductCode"].ToString();
                decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                ///*******************************************
                // * Add in the Purchase Price History
                // * ****************************************/
                //if (lngVariationMatrixID != 0)
                //{
                //    // Update MatrixPackagePriceHistory first to get the history
                //    clsMatrixPackagePriceHistoryDetails = new MatrixPackagePriceHistoryDetails();
                //    clsMatrixPackagePriceHistoryDetails.UID = clsTransferOutDetails.TransferrerID;
                //    clsMatrixPackagePriceHistoryDetails.PackageID = clsMatrixPackage.GetPackageID(lngVariationMatrixID, intProductUnitID);
                //    clsMatrixPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsMatrixPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                //    clsMatrixPackagePriceHistoryDetails.Price = -1;
                //    clsMatrixPackagePriceHistoryDetails.VAT = -1;
                //    clsMatrixPackagePriceHistoryDetails.EVAT = -1;
                //    clsMatrixPackagePriceHistoryDetails.LocalTax = -1;
                //    clsMatrixPackagePriceHistoryDetails.Remarks = "Based on TransferOut #: " + clsTransferOutDetails.TransferOutNo;
                //    MatrixPackagePriceHistory clsMatrixPackagePriceHistory = new MatrixPackagePriceHistory(base.Connection, base.Transaction);
                //    clsMatrixPackagePriceHistory.Insert(clsMatrixPackagePriceHistoryDetails);
                //}
                //else
                //{
                //    // Update ProductPackagePriceHistory first to get the history
                //    clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                //    clsProductPackagePriceHistoryDetails.UID = clsTransferOutDetails.TransferrerID;
                //    clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                //    clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsProductPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                //    clsProductPackagePriceHistoryDetails.Price = -1;
                //    clsProductPackagePriceHistoryDetails.VAT = -1;
                //    clsProductPackagePriceHistoryDetails.EVAT = -1;
                //    clsProductPackagePriceHistoryDetails.LocalTax = -1;
                //    clsProductPackagePriceHistoryDetails.Remarks = "Based on TransferOut #: " + clsTransferOutDetails.TransferOutNo;
                //    ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                //    clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);
                //}

                /*******************************************
                 * Add to Inventory
                 * ****************************************/
                //clsProduct.AddQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity);
                //}
                // July 26, 2011: change the above codes to the following
                clsProduct.SubtractQuantity(clsTransferOutDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_TRANSFER_OUT), DateTime.Now, clsTransferOutDetails.TransferOutNo, clsTransferOutDetails.TransferrerName);

                ///*******************************************
                // * Update Purchasing Information
                // * ****************************************/
                //clsProduct.UpdatePurchasing(lngProductID, clsTransferOutDetails.SupplierID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.UpdatePurchasing(lngVariationMatrixID, clsTransferOutDetails.SupplierID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                //}

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate = clsTransferOutDetails.DeliveryDate;
                clsInventoryDetails.ReferenceNo = clsTransferOutDetails.TransferOutNo;
                clsInventoryDetails.ContactID = clsTransferOutDetails.SupplierID;
                clsInventoryDetails.ContactCode = clsTransferOutDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.TransferOutQuantity = decQuantity;
                clsInventoryDetails.TransferOutCost = decItemCost - decVAT;
                clsInventoryDetails.TransferOutVAT = decItemCost;	// TransferOut Cost with VAT

                clsInventory.Insert(clsInventoryDetails);

                /*******************************************
				 * Added April 28, 2010 4:20PM
                 * Update Selling Information when TransferOut is posted
				 * ****************************************/
                //clsProduct.UpdateSellingIncludingAllMatrixWithSameQuantityAndUnit(lngProductID, clsTransferOutDetails.SupplierID, intProductUnitID, decimal.Parse(myReader["SellingPrice");
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.UpdateSellingWithSameQuantityAndUnit(lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, decimal.Parse(myReader["SellingPrice");
                //}

                /*******************************************
				 * Added April 28, 2010 4:20PM
                 * Update the purchase price history to check who has the lowest price.
				 * ****************************************/
                //ProductPurchasePriceHistoryDetails clsProductPurchasePriceHistoryDetails = new ProductPurchasePriceHistoryDetails();
                //clsProductPurchasePriceHistoryDetails.ProductID = lngProductID;
                //clsProductPurchasePriceHistoryDetails.MatrixID = lngVariationMatrixID;
                //clsProductPurchasePriceHistoryDetails.SupplierID = clsTransferOutDetails.SupplierID;
                //clsProductPurchasePriceHistoryDetails.PurchasePrice = decUnitCost;
                //clsProductPurchasePriceHistoryDetails.PurchaseDate = clsTransferOutDetails.TransferOutDate;
                //clsProductPurchasePriceHistoryDetails.Remarks = clsTransferOutDetails.TransferOutNo;
                //ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(base.Connection, base.Transaction);
                //clsProductPurchasePriceHistory.AddToList(clsProductPurchasePriceHistoryDetails);
            }

        }
Ejemplo n.º 9
0
		public long Insert(PODetails Details)
		{
			try 
			{
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                APLinkConfigDetails clsAPLinkConfigDetails = clsERPConfig.APLinkDetails();

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

				string SQL = "INSERT INTO tblPO (" +
								"PONo, " +
								"PODate, " +
								"SupplierID, " +
								"SupplierCode, " +
								"SupplierContact, " +
								"SupplierAddress, " +
								"SupplierTelephoneNo, " +
								"SupplierModeOfTerms, " +
								"SupplierTerms, " +
                                "SupplierTINNo, " +
                                "SupplierLTONo, " +
								"RequiredDeliveryDate, " +
                                "RID, " +
								"BranchID, " +
								"PurchaserID, " +
                                "PurchaserName, " +
								"Status, " +
								"Remarks, " +
                                "ChartOfAccountIDAPTracking, " +
                                "ChartOfAccountIDAPBills, " +
                                "ChartOfAccountIDAPFreight, " +
                                "ChartOfAccountIDAPVDeposit, " +
                                "ChartOfAccountIDAPContra, " +
                                "ChartOfAccountIDAPLatePayment, " +
                                "IncludeIneSales" +
							") VALUES (" +
                                "@PONo, " +
                                "@PODate, " +
                                "@SupplierID, " +
                                "@SupplierCode, " +
                                "@SupplierContact, " +
                                "@SupplierAddress, " +
                                "@SupplierTelephoneNo, " +
                                "@SupplierModeOfTerms, " +
                                "@SupplierTerms, " +
                                "@SupplierTINNo, " +
                                "@SupplierLTONo, " +
                                "@RequiredDeliveryDate, " +
                                "@RID, " +
                                "@BranchID, " +
                                "@PurchaserID, " +
                                "@PurchaserName, " +
                                "@Status, " +
                                "@Remarks, " +
                                "@ChartOfAccountIDAPTracking, " +
                                "@ChartOfAccountIDAPBills, " +
                                "@ChartOfAccountIDAPFreight, " +
                                "@ChartOfAccountIDAPVDeposit, " +
                                "@ChartOfAccountIDAPContra, " +
                                "@ChartOfAccountIDAPLatePayment, " +
                                "@IncludeIneSales" +
							");";
				
                cmd.Parameters.AddWithValue("@PONo", Details.PONo);
				cmd.Parameters.AddWithValue("@PODate", Details.PODate.ToString("yyyy-MM-dd HH:mm:ss"));
				cmd.Parameters.AddWithValue("@SupplierID", Details.SupplierID);
				cmd.Parameters.AddWithValue("@SupplierCode", Details.SupplierCode);
				cmd.Parameters.AddWithValue("@SupplierContact", Details.SupplierContact);
                cmd.Parameters.AddWithValue("@SupplierAddress", Details.SupplierAddress);
                cmd.Parameters.AddWithValue("@SupplierTelephoneNo", Details.SupplierTelephoneNo);
                cmd.Parameters.AddWithValue("@SupplierModeOfTerms", Details.SupplierModeOfTerms);
                cmd.Parameters.AddWithValue("@SupplierTerms", Details.SupplierTerms);
                cmd.Parameters.AddWithValue("@SupplierTINNo", Details.SupplierTINNo);
                cmd.Parameters.AddWithValue("@SupplierLTONo", Details.SupplierLTONo);
                cmd.Parameters.AddWithValue("@RequiredDeliveryDate", Details.RequiredDeliveryDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@RID", Details.RID);
                cmd.Parameters.AddWithValue("@BranchID", Details.BranchID);
                cmd.Parameters.AddWithValue("@PurchaserID", Details.PurchaserID);
                cmd.Parameters.AddWithValue("@PurchaserName", Details.PurchaserName);
                cmd.Parameters.AddWithValue("@Status", Details.Status.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPTracking", clsAPLinkConfigDetails.ChartOfAccountIDAPTracking);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPBills", clsAPLinkConfigDetails.ChartOfAccountIDAPBills);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPFreight", clsAPLinkConfigDetails.ChartOfAccountIDAPFreight);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPVDeposit", clsAPLinkConfigDetails.ChartOfAccountIDAPVDeposit);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPContra", clsAPLinkConfigDetails.ChartOfAccountIDAPContra);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPLatePayment", clsAPLinkConfigDetails.ChartOfAccountIDAPLatePayment);
                cmd.Parameters.AddWithValue("@IncludeIneSales", Details.IncludeIneSales);

                cmd.CommandText = SQL;
                base.ExecuteNonQuery(cmd);

                return Int64.Parse(base.getLAST_INSERT_ID(this));
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Ejemplo n.º 10
0
        private void AddItemToInventory(long TransferInID)
        {
            try
            {
                TransferInDetails clsTransferInDetails = Details(TransferInID);
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

                TransferInItem clsTransferInItem = new TransferInItem(base.Connection, base.Transaction);
                ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
                Products clsProduct = new Products(base.Connection, base.Transaction);
                ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);

                Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
                InventoryDetails clsInventoryDetails;

                ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

                System.Data.DataTable dt = clsTransferInItem.ListAsDataTable(TransferInID, "TransferInItemID", SortOption.Ascending);
            
                foreach(System.Data.DataRow dr in dt.Rows)
                {
                    long lngProductID = long.Parse(dr["ProductID"].ToString());
                    int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                    decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                    decimal decQuantity = new ProductUnit().GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                    long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString()); 
                    string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                    string strProductCode = "" + dr["ProductCode"].ToString();
                    decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                    decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                    decimal decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                    decimal decVAT = Convert.ToDecimal(dr["VAT"]); // myReader.GetDecimal("VAT");
                    decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                    decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                    /*******************************************
				     * Add in the Price History
				     * ****************************************/
                    // Update ProductPackagePriceHistory first to get the history
                    clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                    clsProductPackagePriceHistoryDetails.UID = clsTransferInDetails.TransferrerID;
                    clsProductPackagePriceHistoryDetails.PackageID = new ProductPackage().GetPackageID(lngProductID, intProductUnitID);
                    clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                    clsProductPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                    clsProductPackagePriceHistoryDetails.Price = decSellingPrice;
                    clsProductPackagePriceHistoryDetails.VAT = decVAT;
                    clsProductPackagePriceHistoryDetails.EVAT = decEVAT;
                    clsProductPackagePriceHistoryDetails.LocalTax = decLocalTax;
                    clsProductPackagePriceHistoryDetails.Remarks = "Based on TransferIn #: " + clsTransferInDetails.TransferInNo;
                    ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                    clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);

                    /*******************************************
                     * Add to Inventory
                     * ****************************************/
                    //clsProduct.AddQuantity(lngProductID, decQuantity);
                    //if (lngVariationMatrixID != 0)
                    //{
                    //    clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity);
                    //}
                    // July 26, 2011: change the above codes to the following
                    clsProduct.AddQuantity(clsTransferInDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_TRANSFER_IN), DateTime.Now, clsTransferInDetails.TransferInNo, clsTransferInDetails.TransferrerName);

                    /*******************************************
                     * Update Purchasing Information
                     * ****************************************/
                    int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                    if (iBaseUnitID != intProductUnitID)
                    {
                        clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsTransferInDetails.SupplierID, iBaseUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                    }
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsTransferInDetails.SupplierID, intProductUnitID, decUnitCost);

                    /*******************************************
                     * Add to Inventory Analysis
                     * ****************************************/
                    clsInventoryDetails = new InventoryDetails();
                    clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                    clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                    clsInventoryDetails.PostingDate = clsTransferInDetails.DeliveryDate;
                    clsInventoryDetails.ReferenceNo = clsTransferInDetails.TransferInNo;
                    clsInventoryDetails.ContactID = clsTransferInDetails.SupplierID;
                    clsInventoryDetails.ContactCode = clsTransferInDetails.SupplierCode;
                    clsInventoryDetails.ProductID = lngProductID;
                    clsInventoryDetails.ProductCode = strProductCode;
                    clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                    clsInventoryDetails.MatrixDescription = strMatrixDescription;
                    clsInventoryDetails.TransferInQuantity = decQuantity;
                    clsInventoryDetails.TransferInCost = decItemCost - decVAT;
                    clsInventoryDetails.TransferInVAT = decItemCost;	// TransferIn Cost with VAT

                    clsInventory.Insert(clsInventoryDetails);

                    /*******************************************
				     * Added April 28, 2010 4:20PM
                     * Update Selling Information when TransferIn is posted
				     * ****************************************/
                    clsProduct.UpdateSellingPrice(lngProductID, lngVariationMatrixID, clsTransferInDetails.SupplierID, intProductUnitID, decimal.Parse(dr["SellingPrice"].ToString()), -1, -1, -1, -1, -1);
                    //if (lngVariationMatrixID != 0)
                    //{
                    //    clsProductVariationsMatrix.UpdateSellingWithSameQuantityAndUnit(lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, decimal.Parse(myReader["SellingPrice");
                    //}

                    /*******************************************
				     * Added April 28, 2010 4:20PM
                     * Update the purchase price history to check who has the lowest price.
				     * ****************************************/
                    ProductPurchasePriceHistoryDetails clsProductPurchasePriceHistoryDetails = new ProductPurchasePriceHistoryDetails();
                    clsProductPurchasePriceHistoryDetails.ProductID = lngProductID;
                    clsProductPurchasePriceHistoryDetails.MatrixID = lngVariationMatrixID;
                    clsProductPurchasePriceHistoryDetails.SupplierID = clsTransferInDetails.SupplierID;
                    clsProductPurchasePriceHistoryDetails.PurchasePrice = decUnitCost;
                    clsProductPurchasePriceHistoryDetails.PurchaseDate = clsTransferInDetails.TransferInDate;
                    clsProductPurchasePriceHistoryDetails.Remarks = clsTransferInDetails.TransferInNo;
                    ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(base.Connection, base.Transaction);
                    clsProductPurchasePriceHistory.AddToList(clsProductPurchasePriceHistoryDetails);
                }
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }

        }
Ejemplo n.º 11
0
		private void Post()
		{
			DateTime DeliveryDate = Convert.ToDateTime(txtPostDate.Text);

			ERPConfig clsERPConfig = new ERPConfig();
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();
			clsERPConfig.CommitAndDispose();
			
			if (clsERPConfigDetails.PostingDateFrom <= DeliveryDate && clsERPConfigDetails.PostingDateTo >= DeliveryDate)
			{
				long DebitMemoID = Convert.ToInt64(lblDebitMemoID.Text);
				string SupplierDRNo = txtSupplierDocNo.Text;

				DebitMemos clsDebitMemos = new DebitMemos();
				clsDebitMemos.Post(DebitMemoID, SupplierDRNo, DeliveryDate);
				clsDebitMemos.CommitAndDispose();

				Common Common = new Common();
				string stParam = "?task=" + Common.Encrypt("list",Session.SessionID) + "&memoid=" + Common.Encrypt(DebitMemoID.ToString(),Session.SessionID);	
				Response.Redirect("Default.aspx" + stParam);
			}
			else
			{
				string stScript = "<Script>";
				stScript += "window.alert('Sorry you cannot post using the delivery date: " + txtPostDate.Text + ". Please enter an allowable posting date.')";
				stScript += "</Script>";
				Response.Write(stScript);	
			}
		}
Ejemplo n.º 12
0
		public long Insert(SODetails Details)
		{
			try
			{
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
				ARLinkConfigDetails clsARLinkConfigDetails = clsERPConfig.ARLinkDetails();

				string SQL = "INSERT INTO tblSO (" +
								"SONo, " +
								"SODate, " +
								"CustomerID, " +
								"CustomerCode, " +
								"CustomerContact, " +
								"CustomerAddress, " +
								"CustomerTelephoneNo, " +
								"CustomerModeOfTerms, " +
								"CustomerTerms, " +
								"RequiredDeliveryDate, " +
								"BranchID, " +
								"SellerID, " +
								"SellerName, " +
								"Status, " +
								"Remarks, " +
								"ChartOfAccountIDARTracking, " +
								"ChartOfAccountIDARBills, " +
								"ChartOfAccountIDARFreight, " +
								"ChartOfAccountIDARVDeposit, " +
								"ChartOfAccountIDARContra, " +
								"ChartOfAccountIDARLatePayment" +
							") VALUES (" +
								"@SONo, " +
								"@SODate, " +
								"@CustomerID, " +
								"@CustomerCode, " +
								"@CustomerContact, " +
								"@CustomerAddress, " +
								"@CustomerTelephoneNo, " +
								"@CustomerModeOfTerms, " +
								"@CustomerTerms, " +
								"@RequiredDeliveryDate, " +
								"@BranchID, " +
								"@SellerID, " +
								"@SellerName, " +
								"@Status, " +
								"@Remarks, " +
								"@ChartOfAccountIDARTracking, " +
								"@ChartOfAccountIDARBills, " +
								"@ChartOfAccountIDARFreight, " +
								"@ChartOfAccountIDARVDeposit, " +
								"@ChartOfAccountIDARContra, " +
								"@ChartOfAccountIDARLatePayment" +
							");";

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

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

				MySqlParameter prmSODate = new MySqlParameter("@SODate",MySqlDbType.DateTime);
				prmSODate.Value = Details.SODate.ToString("yyyy-MM-dd HH:mm:ss");
				cmd.Parameters.Add(prmSODate);

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

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

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

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

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

				MySqlParameter prmCustomerModeOfTerms = new MySqlParameter("@CustomerModeOfTerms",MySqlDbType.Int16);
				prmCustomerModeOfTerms.Value = Details.CustomerModeOfTerms;
				cmd.Parameters.Add(prmCustomerModeOfTerms);

				MySqlParameter prmCustomerTerms = new MySqlParameter("@CustomerTerms",MySqlDbType.Int16);
				prmCustomerTerms.Value = Details.CustomerTerms;
				cmd.Parameters.Add(prmCustomerTerms);

				MySqlParameter prmRequiredDeliveryDate = new MySqlParameter("@RequiredDeliveryDate",MySqlDbType.DateTime);
				prmRequiredDeliveryDate.Value = Details.RequiredDeliveryDate.ToString("yyyy-MM-dd HH:mm:ss");
				cmd.Parameters.Add(prmRequiredDeliveryDate);

				MySqlParameter prmBranchID = new MySqlParameter("@BranchID",MySqlDbType.Int16);
				prmBranchID.Value = Details.BranchID;
				cmd.Parameters.Add(prmBranchID);

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

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

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

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

				MySqlParameter prmChartOfAccountIDARTracking = new MySqlParameter("@ChartOfAccountIDARTracking",MySqlDbType.Int32);
				prmChartOfAccountIDARTracking.Value = clsARLinkConfigDetails.ChartOfAccountIDARTracking;
				cmd.Parameters.Add(prmChartOfAccountIDARTracking);

				MySqlParameter prmChartOfAccountIDARBills = new MySqlParameter("@ChartOfAccountIDARBills",MySqlDbType.Int32);
				prmChartOfAccountIDARBills.Value = clsARLinkConfigDetails.ChartOfAccountIDARBills;
				cmd.Parameters.Add(prmChartOfAccountIDARBills);

				MySqlParameter prmChartOfAccountIDARFreight = new MySqlParameter("@ChartOfAccountIDARFreight",MySqlDbType.Int32);
				prmChartOfAccountIDARFreight.Value = clsARLinkConfigDetails.ChartOfAccountIDARFreight;
				cmd.Parameters.Add(prmChartOfAccountIDARFreight);

				MySqlParameter prmChartOfAccountIDARVDeposit = new MySqlParameter("@ChartOfAccountIDARVDeposit",MySqlDbType.Int32);
				prmChartOfAccountIDARVDeposit.Value = clsARLinkConfigDetails.ChartOfAccountIDARVDeposit;
				cmd.Parameters.Add(prmChartOfAccountIDARVDeposit);

				MySqlParameter prmChartOfAccountIDARContra = new MySqlParameter("@ChartOfAccountIDARContra",MySqlDbType.Int32);
				prmChartOfAccountIDARContra.Value = clsARLinkConfigDetails.ChartOfAccountIDARContra;
				cmd.Parameters.Add(prmChartOfAccountIDARContra);

				MySqlParameter prmChartOfAccountIDARLatePayment = new MySqlParameter("@ChartOfAccountIDARLatePayment",MySqlDbType.Int32);
				prmChartOfAccountIDARLatePayment.Value = clsARLinkConfigDetails.ChartOfAccountIDARLatePayment;
				cmd.Parameters.Add(prmChartOfAccountIDARLatePayment);

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

                return iID;
			}

			catch (Exception ex)
			{
                throw base.ThrowException(ex);
			}
		}
Ejemplo n.º 13
0
		public void Update(SODetails Details)
		{
			try
			{
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
				ARLinkConfigDetails clsARLinkConfigDetails = clsERPConfig.ARLinkDetails();

				string SQL = "UPDATE tblSO SET " +
								"SONo					=	@SONo, " +
								"SODate					=	@SODate, " +
								"CustomerID				=	@CustomerID, " +
								"CustomerCode			=	@CustomerCode, " +
								"CustomerContact		=	@CustomerContact, " +
								"CustomerAddress		=	@CustomerAddress, " +
								"CustomerTelephoneNo	=	@CustomerTelephoneNo, " +
								"CustomerModeOfTerms	=	@CustomerModeOfTerms, " +
								"CustomerTerms			=	@CustomerTerms, " +
								"RequiredDeliveryDate	=	@RequiredDeliveryDate, " +
								"BranchID				=	@BranchID, " +
								"SellerID			    =	@SellerID, " +
								"SellerName             =   @SellerName, " +
								"Remarks                =   @Remarks, " +
								"ChartOfAccountIDARTracking     = @ChartOfAccountIDARTracking, " +
								"ChartOfAccountIDARBills        = @ChartOfAccountIDARBills, " +
								"ChartOfAccountIDARFreight      = @ChartOfAccountIDARFreight, " +
								"ChartOfAccountIDARVDeposit     = @ChartOfAccountIDARVDeposit, " +
								"ChartOfAccountIDARContra       = @ChartOfAccountIDARContra, " +
								"ChartOfAccountIDARLatePayment  = @ChartOfAccountIDARLatePayment " +
							"WHERE SOID = @SOID;";

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

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

				MySqlParameter prmSODate = new MySqlParameter("@SODate",MySqlDbType.DateTime);
				prmSODate.Value = Details.SODate.ToString("yyyy-MM-dd HH:mm:ss");
				cmd.Parameters.Add(prmSODate);

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

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

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

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

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

				MySqlParameter prmCustomerModeOfTerms = new MySqlParameter("@CustomerModeOfTerms",MySqlDbType.Int16);
				prmCustomerModeOfTerms.Value = Details.CustomerModeOfTerms;
				cmd.Parameters.Add(prmCustomerModeOfTerms);

				MySqlParameter prmCustomerTerms = new MySqlParameter("@CustomerTerms",MySqlDbType.Int16);
				prmCustomerTerms.Value = Details.CustomerTerms;
				cmd.Parameters.Add(prmCustomerTerms);

				MySqlParameter prmRequiredDeliveryDate = new MySqlParameter("@RequiredDeliveryDate",MySqlDbType.DateTime);
				prmRequiredDeliveryDate.Value = Details.RequiredDeliveryDate.ToString("yyyy-MM-dd HH:mm:ss");
				cmd.Parameters.Add(prmRequiredDeliveryDate);

				MySqlParameter prmBranchID = new MySqlParameter("@BranchID",MySqlDbType.Int16);
				prmBranchID.Value = Details.BranchID;
				cmd.Parameters.Add(prmBranchID);

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

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

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

				MySqlParameter prmChartOfAccountIDARTracking = new MySqlParameter("@ChartOfAccountIDARTracking",MySqlDbType.Int32);
				prmChartOfAccountIDARTracking.Value = clsARLinkConfigDetails.ChartOfAccountIDARTracking;
				cmd.Parameters.Add(prmChartOfAccountIDARTracking);

				MySqlParameter prmChartOfAccountIDARBills = new MySqlParameter("@ChartOfAccountIDARBills",MySqlDbType.Int32);
				prmChartOfAccountIDARBills.Value = clsARLinkConfigDetails.ChartOfAccountIDARBills;
				cmd.Parameters.Add(prmChartOfAccountIDARBills);

				MySqlParameter prmChartOfAccountIDARFreight = new MySqlParameter("@ChartOfAccountIDARFreight",MySqlDbType.Int32);
				prmChartOfAccountIDARFreight.Value = clsARLinkConfigDetails.ChartOfAccountIDARFreight;
				cmd.Parameters.Add(prmChartOfAccountIDARFreight);

				MySqlParameter prmChartOfAccountIDARVDeposit = new MySqlParameter("@ChartOfAccountIDARVDeposit",MySqlDbType.Int32);
				prmChartOfAccountIDARVDeposit.Value = clsARLinkConfigDetails.ChartOfAccountIDARVDeposit;
				cmd.Parameters.Add(prmChartOfAccountIDARVDeposit);

				MySqlParameter prmChartOfAccountIDARContra = new MySqlParameter("@ChartOfAccountIDARContra",MySqlDbType.Int32);
				prmChartOfAccountIDARContra.Value = clsARLinkConfigDetails.ChartOfAccountIDARContra;
				cmd.Parameters.Add(prmChartOfAccountIDARContra);

				MySqlParameter prmChartOfAccountIDARLatePayment = new MySqlParameter("@ChartOfAccountIDARLatePayment",MySqlDbType.Int32);
				prmChartOfAccountIDARLatePayment.Value = clsARLinkConfigDetails.ChartOfAccountIDARLatePayment;
				cmd.Parameters.Add(prmChartOfAccountIDARLatePayment);

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

                base.ExecuteNonQuery(cmd);
			}

			catch (Exception ex)
			{
                throw base.ThrowException(ex);
			}
		}
Ejemplo n.º 14
0
		private void AddItemToInventory(long CreditMemoID)
		{

			SOReturnDetails clsSOReturnDetails = Details(CreditMemoID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			SOReturnItems clsSOReturnItems = new SOReturnItems(base.Connection, base.Transaction);
			ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
			Products clsProduct = new Products(base.Connection, base.Transaction);
			ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsSOReturnItems.ListAsDataTable(CreditMemoID);

            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = long.Parse(dr["ProductID"].ToString());
                int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string strProductCode = "" + dr["ProductCode"].ToString();
                decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

				/*******************************************
				 * Add from Inventory
				 * ****************************************/
				// clsProduct.AddQuantity(ProductID, Quantity);
				// if (VariationMatrixID != 0){ clsProductVariationsMatrix.AddQuantity(VariationMatrixID, Quantity); }
                // July 28, 2011: change the above codes to the following
                clsProduct.AddQuantity(clsSOReturnDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_SALES_RETURN), DateTime.Now, clsSOReturnDetails.CNNo, clsSOReturnDetails.SellerName);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				InventoryDetails clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsSOReturnDetails.PostingDate;
				clsInventoryDetails.ReferenceNo = clsSOReturnDetails.CNNo;
				clsInventoryDetails.ContactID = clsSOReturnDetails.CustomerID;
				clsInventoryDetails.ContactCode = clsSOReturnDetails.CustomerCode;
                clsInventoryDetails.ProductID = lngProductID;
				clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
				clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.SReturnQuantity = decQuantity;
				clsInventoryDetails.SReturnCost = decItemCost - decVAT;
				clsInventoryDetails.SReturnVAT = decItemCost;	//Purchase Return with VAT

				clsInventory.Insert(clsInventoryDetails);

			}
            //myReader.Close();

		}
Ejemplo n.º 15
0
        private void AddItemToInventory(long WBranchTransferID)
        {
            WBranchTransferDetails clsWBranchTransferDetails = Details(WBranchTransferID);
            ERPConfig        clsERPConfig        = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            WBranchTransferItem clsWBranchTransferItem = new WBranchTransferItem(base.Connection, base.Transaction);
            ProductUnit         clsProductUnit         = new ProductUnit(base.Connection, base.Transaction);
            Products            clsProduct             = new Products(base.Connection, base.Transaction);

            Inventory        clsInventory = new Inventory(base.Connection, base.Transaction);
            InventoryDetails clsInventoryDetails;

            System.Data.DataTable dt = clsWBranchTransferItem.ListAsDataTable(WBranchTransferID, "WBranchTransferItemID", SortOption.Ascending);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID     = Int64.Parse(dr["ProductID"].ToString());
                int  intProductUnitID = Int16.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity     = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long    lngVariationMatrixID = Int64.Parse(dr["VariationMatrixID"].ToString());
                string  strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string  strProductCode       = "" + dr["ProductCode"].ToString();
                string  strProductUnitCode   = "" + dr["ProductUnitCode"].ToString();
                decimal decUnitCost          = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost          = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                /*******************************************
                 * Subtract BranchIDFrom then Add to BranchIDTo -- Inventory
                 * ****************************************/
                clsProduct.SubtractQuantity(clsWBranchTransferDetails.BranchIDFrom, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_BRANCH_TRANSFER_FROM) + " " + clsWBranchTransferDetails.BranchCodeFrom + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsWBranchTransferDetails.WBranchTransferNo, clsWBranchTransferDetails.TransferrerName);
                clsProduct.AddQuantity(clsWBranchTransferDetails.BranchIDTo, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_BRANCH_TRANSFER_TO) + " " + clsWBranchTransferDetails.BranchCodeTo + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsWBranchTransferDetails.WBranchTransferNo, clsWBranchTransferDetails.TransferrerName);

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom   = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo     = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate       = clsWBranchTransferDetails.DeliveryDate;
                clsInventoryDetails.ReferenceNo       = clsWBranchTransferDetails.WBranchTransferNo;
                clsInventoryDetails.ContactID         = Constants.C_RETAILPLUS_SUPPLIERID;
                clsInventoryDetails.ContactCode       = Constants.C_RETAILPLUS_SUPPLIER;
                clsInventoryDetails.ProductID         = lngProductID;
                clsInventoryDetails.ProductCode       = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;

                clsInventoryDetails.PurchaseCost = decItemCost - decVAT;
                clsInventoryDetails.PurchaseVAT  = decItemCost; // Purchase Cost with VAT

                // insert into branchid from with minus quantity
                clsInventoryDetails.BranchID         = clsWBranchTransferDetails.BranchIDFrom;
                clsInventoryDetails.PurchaseQuantity = -decQuantity;
                clsInventory.Insert(clsInventoryDetails);

                // insert into branchid to with add quantity
                clsInventoryDetails.BranchID         = clsWBranchTransferDetails.BranchIDTo;
                clsInventoryDetails.PurchaseQuantity = decQuantity;
                clsInventory.Insert(clsInventoryDetails);
            }
        }
Ejemplo n.º 16
0
		private void SaveRecord()
		{

            APLinkConfigDetails clsDetails = new APLinkConfigDetails();

            clsDetails.ChartOfAccountIDAPTracking = Convert.ToInt32(cboChartOfAccountAPTracking.SelectedItem.Value);
            clsDetails.ChartOfAccountIDAPBills = Convert.ToInt32(cboChartOfAccountAPBills.SelectedItem.Value);
            clsDetails.ChartOfAccountIDAPFreight = Convert.ToInt32(cboChartOfAccountAPFreight.SelectedItem.Value);
            clsDetails.ChartOfAccountIDAPVDeposit = Convert.ToInt32(cboChartOfAccountAPVDeposit.SelectedItem.Value);
            clsDetails.ChartOfAccountIDAPContra = Convert.ToInt32(cboChartOfAccountAPContra.SelectedItem.Value);
            clsDetails.ChartOfAccountIDAPLatePayment = Convert.ToInt32(cboChartOfAccountAPLatePayment.SelectedItem.Value);

			ERPConfig clsERPConfig = new ERPConfig();
			clsERPConfig.UpdateAPLinkConfig(clsDetails);

			clsERPConfig.CommitAndDispose();
		}
Ejemplo n.º 17
0
        public long Insert(SOReturnDetails Details)
		{
			try 
			{
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                ARLinkConfigDetails clsARLinkConfigDetails = clsERPConfig.ARLinkDetails();

				string SQL = "INSERT INTO tblSOCreditMemo (" +
								"CNNo, " +
								"CNDate, " +
								"CustomerID, " +
								"CustomerCode, " +
								"CustomerContact, " +
								"CustomerAddress, " +
								"CustomerTelephoneNo, " +
								"CustomerModeOfTerms, " +
								"CustomerTerms, " +
								"RequiredPostingDate, " +
								"BranchID, " +
								"SellerID, " +
                                "SellerName, " +
                                "SOReturnStatus, " +
                                "CreditMemoStatus, " +
                                "Remarks, " +
                                "ChartOfAccountIDARTracking, " +
                                "ChartOfAccountIDARBills, " +
                                "ChartOfAccountIDARFreight, " +
                                "ChartOfAccountIDARVDeposit, " +
                                "ChartOfAccountIDARContra, " +
                                "ChartOfAccountIDARLatePayment" +
							") VALUES (" +
								"@CNNo, " +
								"@CNDate, " +
								"@CustomerID, " +
								"@CustomerCode, " +
								"@CustomerContact, " +
								"@CustomerAddress, " +
								"@CustomerTelephoneNo, " +
								"@CustomerModeOfTerms, " +
								"@CustomerTerms, " +
								"@RequiredPostingDate, " +
								"@BranchID, " +
                                "@SellerID, " +
                                "@SellerName, " +
                                "@SOReturnStatus, " +
                                "@CreditMemoStatus, " +
                                "@Remarks, " +
                                "@ChartOfAccountIDARTracking, " +
                                "@ChartOfAccountIDARBills, " +
                                "@ChartOfAccountIDARFreight, " +
                                "@ChartOfAccountIDARVDeposit, " +
                                "@ChartOfAccountIDARContra, " +
                                "@ChartOfAccountIDARLatePayment" +
							");";
				  
				
	 			
				MySqlCommand cmd = new MySqlCommand();
				
				
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
				cmd.Parameters.AddWithValue("@CNNo", Details.CNNo);
				cmd.Parameters.AddWithValue("@CNDate", Details.CNDate.ToString("yyyy-MM-dd HH:mm:ss"));
				cmd.Parameters.AddWithValue("@CustomerID", Details.CustomerID);
				cmd.Parameters.AddWithValue("@CustomerCode", Details.CustomerCode);
				cmd.Parameters.AddWithValue("@CustomerContact", Details.CustomerContact);			 
				cmd.Parameters.AddWithValue("@CustomerAddress", Details.CustomerAddress);	
				cmd.Parameters.AddWithValue("@CustomerTelephoneNo", Details.CustomerTelephoneNo);		 
				cmd.Parameters.AddWithValue("@CustomerModeOfTerms", Details.CustomerModeOfTerms);	
				cmd.Parameters.AddWithValue("@CustomerTerms", Details.CustomerTerms);	
				cmd.Parameters.AddWithValue("@RequiredPostingDate", Details.RequiredPostingDate.ToString("yyyy-MM-dd HH:mm:ss"));
				cmd.Parameters.AddWithValue("@BranchID", Details.BranchID);				 
				cmd.Parameters.AddWithValue("@SellerID", Details.SellerID);
                cmd.Parameters.AddWithValue("@SellerName", Details.SellerName);
				cmd.Parameters.AddWithValue("@SOReturnStatus", Details.ReturnStatus.ToString("d"));
				cmd.Parameters.AddWithValue("@CreditMemoStatus", CreditMemoStatus.Posted.ToString("d"));
				cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARTracking", clsARLinkConfigDetails.ChartOfAccountIDARTracking);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARBills", clsARLinkConfigDetails.ChartOfAccountIDARBills);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARFreight", clsARLinkConfigDetails.ChartOfAccountIDARFreight);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARVDeposit", clsARLinkConfigDetails.ChartOfAccountIDARVDeposit);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARContra", clsARLinkConfigDetails.ChartOfAccountIDARContra);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARLatePayment", clsARLinkConfigDetails.ChartOfAccountIDARLatePayment);

				base.ExecuteNonQuery(cmd);

				SQL = "SELECT LAST_INSERT_ID();";
				
				cmd.Parameters.Clear(); 
				cmd.CommandText = SQL;
				
				MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult);
				
				Int64 iID = 0;

				while (myReader.Read()) 
				{
					iID = myReader.GetInt64(0);
				}

				myReader.Close();

				return iID;
			}

			catch (Exception ex)
			{
				
				
				{
					
					 
					
					
				}

				throw base.ThrowException(ex);
			}	
		}
Ejemplo n.º 18
0
        private Int64 SaveRecord()
        {
            ContactDetails clsDetails = new ContactDetails();

            ERPConfig clsERPConfig = new ERPConfig();
            BarcodeHelper ean13 = new BarcodeHelper(BarcodeHelper.CustomerCode_Country_Code, BarcodeHelper.CustomerCode_ManufacturerCode, clsERPConfig.get_LastCustomerCode());
            clsDetails.ContactCode = ean13.CountryCode + ean13.ManufacturerCode + ean13.ProductCode + ean13.ChecksumDigit;
            clsERPConfig.CommitAndDispose();

            clsDetails.ContactName = txtLastName.Text + ", " + txtFirstName.Text + " " + txtMiddleName.Text;
            clsDetails.ContactGroupID = Convert.ToInt32(cboGroup.SelectedItem.Value);
            clsDetails.ModeOfTerms = ModeOfTerms.Months;
            clsDetails.Terms = 0;
            clsDetails.Address = txtAddress1.Text + " " + txtAddress2.Text + " " + txtCity.Text + " " + txtState.Text + " " + txtZipCode.Text;
            clsDetails.BusinessName = txtBusinessName.Text;
            clsDetails.TelephoneNo = txtBusinessPhoneNo.Text;
            clsDetails.Remarks = txtRemarks.Text;
            clsDetails.Debit = 0;
            clsDetails.Credit = 0;
            clsDetails.IsCreditAllowed = false;
            clsDetails.CreditLimit = 0;
            clsDetails.DepartmentID = Convert.ToInt16(cboDepartment.SelectedItem.Value);
            clsDetails.PositionID = Convert.ToInt16(cboPosition.SelectedItem.Value);

            DateTime dteBirthDate = Constants.C_DATE_MIN_VALUE;
            DateTime dteSpouseBirthDate = Constants.C_DATE_MIN_VALUE;
            DateTime dteAnniversaryDate = Constants.C_DATE_MIN_VALUE;

            dteBirthDate = DateTime.TryParse(txtBirthDate.Text, out dteBirthDate) ? dteBirthDate : Constants.C_DATE_MIN_VALUE;
            dteSpouseBirthDate = DateTime.TryParse(txtSpouseBirthDate.Text, out dteSpouseBirthDate) ? dteSpouseBirthDate : Constants.C_DATE_MIN_VALUE;
            dteAnniversaryDate = DateTime.TryParse(txtAnniversaryDate.Text, out dteAnniversaryDate) ? dteAnniversaryDate : Constants.C_DATE_MIN_VALUE;

            ContactAddOnDetails clsAddOnDetails = new ContactAddOnDetails();
            clsAddOnDetails.ContactID = clsDetails.ContactID;
            clsAddOnDetails.Salutation = cboSalutation.SelectedItem.Value;
            clsAddOnDetails.FirstName = txtFirstName.Text;
            clsAddOnDetails.MiddleName = txtMiddleName.Text;
            clsAddOnDetails.LastName = txtLastName.Text;
            clsAddOnDetails.SpouseName = txtSpouseName.Text;
            clsAddOnDetails.BirthDate = dteBirthDate;
            clsAddOnDetails.SpouseBirthDate = dteSpouseBirthDate;
            clsAddOnDetails.AnniversaryDate = dteAnniversaryDate;
            clsAddOnDetails.Address1 = txtAddress1.Text;
            clsAddOnDetails.Address2 = txtAddress2.Text;
            clsAddOnDetails.City = txtCity.Text;
            clsAddOnDetails.State = txtState.Text;
            clsAddOnDetails.ZipCode = txtZipCode.Text;
            clsAddOnDetails.CountryID = int.Parse(cboCountry.SelectedItem.Value);
            clsAddOnDetails.CountryCode = cboCountry.SelectedItem.Text;
            clsAddOnDetails.BusinessPhoneNo = txtBusinessPhoneNo.Text;
            clsAddOnDetails.HomePhoneNo = txtHomePhoneNo.Text;
            clsAddOnDetails.MobileNo = txtMobileNo.Text;
            clsAddOnDetails.FaxNo = txtFaxNo.Text;
            clsAddOnDetails.EmailAddress = txtEmailAddress.Text;

            clsDetails.AdditionalDetails = clsAddOnDetails;

            Contacts clsContact = new Contacts();
            Int64 id = clsContact.Insert(clsDetails);
            clsContact.CommitAndDispose();

            return id;
        }
Ejemplo n.º 19
0
		public void Update(POReturnDetails Details)
		{
			try 
			{
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                APLinkConfigDetails clsAPLinkConfigDetails = clsERPConfig.APLinkDetails();

				string SQL=	"UPDATE tblPODebitMemo SET " + 
								"MemoNo				=	@MemoNo, " +
								"MemoDate				=	@MemoDate, " +
								"SupplierID				=	@SupplierID, " +
								"SupplierCode			=	@SupplierCode, " +
								"SupplierContact		=	@SupplierContact, " +
								"SupplierAddress		=	@SupplierAddress, " +
								"SupplierTelephoneNo	=	@SupplierTelephoneNo, " +
								"SupplierModeOfTerms	=	@SupplierModeOfTerms, " +
								"SupplierTerms			=	@SupplierTerms, " +
								"RequiredPostingDate	=	@RequiredPostingDate, " +
                                "BranchID				=	@BranchID, " +
                                "PurchaserID			=	@PurchaserID, " +
                                "PurchaserName          =   @PurchaserName, " +
                                "Remarks                =   @Remarks, " +
                                "ChartOfAccountIDAPTracking     = @ChartOfAccountIDAPTracking, " +
                                "ChartOfAccountIDAPBills        = @ChartOfAccountIDAPBills, " +
                                "ChartOfAccountIDAPFreight      = @ChartOfAccountIDAPFreight, " +
                                "ChartOfAccountIDAPVDeposit     = @ChartOfAccountIDAPVDeposit, " +
                                "ChartOfAccountIDAPContra       = @ChartOfAccountIDAPContra, " +
                                "ChartOfAccountIDAPLatePayment  = @ChartOfAccountIDAPLatePayment " +
							"WHERE DebitMemoID = @DebitMemoID;";
				  
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
				MySqlParameter prmReturnNo = new MySqlParameter("@MemoNo",MySqlDbType.String);
				prmReturnNo.Value = Details.MemoNo;
				cmd.Parameters.Add(prmReturnNo);

				MySqlParameter prmReturnDate = new MySqlParameter("@MemoDate",MySqlDbType.DateTime);
				prmReturnDate.Value = Details.MemoDate.ToString("yyyy-MM-dd HH:mm:ss");
				cmd.Parameters.Add(prmReturnDate);

				MySqlParameter prmSupplierID = new MySqlParameter("@SupplierID",MySqlDbType.Int64);						
				prmSupplierID.Value = Details.SupplierID;
				cmd.Parameters.Add(prmSupplierID);
								 
				MySqlParameter prmSupplierCode = new MySqlParameter("@SupplierCode",MySqlDbType.String);
				prmSupplierCode.Value = Details.SupplierCode;
				cmd.Parameters.Add(prmSupplierCode);
		 
				MySqlParameter prmSupplierContact = new MySqlParameter("@SupplierContact",MySqlDbType.String);
				prmSupplierContact.Value = Details.SupplierContact;
				cmd.Parameters.Add(prmSupplierContact);			 
				
				MySqlParameter prmSupplierAddress = new MySqlParameter("@SupplierAddress",MySqlDbType.String);
				prmSupplierAddress.Value = Details.SupplierAddress;
				cmd.Parameters.Add(prmSupplierAddress);	
				
				MySqlParameter prmSupplierTelephoneNo = new MySqlParameter("@SupplierTelephoneNo",MySqlDbType.String);
				prmSupplierTelephoneNo.Value = Details.SupplierTelephoneNo;
				cmd.Parameters.Add(prmSupplierTelephoneNo);	

				MySqlParameter prmSupplierModeOfTerms = new MySqlParameter("@SupplierModeOfTerms",MySqlDbType.Int16);
				prmSupplierModeOfTerms.Value = Details.SupplierModeOfTerms;
				cmd.Parameters.Add(prmSupplierModeOfTerms);	

				MySqlParameter prmSupplierTerms = new MySqlParameter("@SupplierTerms",MySqlDbType.Int16);
				prmSupplierTerms.Value = Details.SupplierTerms;
				cmd.Parameters.Add(prmSupplierTerms);			 
							 
				MySqlParameter prmRequiredPostingDate = new MySqlParameter("@RequiredPostingDate",MySqlDbType.DateTime);
				prmRequiredPostingDate.Value = Details.RequiredPostingDate.ToString("yyyy-MM-dd HH:mm:ss");
				cmd.Parameters.Add(prmRequiredPostingDate);

                MySqlParameter prmBranchID = new MySqlParameter("@BranchID",MySqlDbType.Int16);
                prmBranchID.Value = Details.BranchID;
                cmd.Parameters.Add(prmBranchID);

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

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

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

                MySqlParameter prmChartOfAccountIDAPTracking = new MySqlParameter("@ChartOfAccountIDAPTracking",MySqlDbType.Int32);
                prmChartOfAccountIDAPTracking.Value = clsAPLinkConfigDetails.ChartOfAccountIDAPTracking;
                cmd.Parameters.Add(prmChartOfAccountIDAPTracking);

                MySqlParameter prmChartOfAccountIDAPBills = new MySqlParameter("@ChartOfAccountIDAPBills",MySqlDbType.Int32);
                prmChartOfAccountIDAPBills.Value = clsAPLinkConfigDetails.ChartOfAccountIDAPBills;
                cmd.Parameters.Add(prmChartOfAccountIDAPBills);

                MySqlParameter prmChartOfAccountIDAPFreight = new MySqlParameter("@ChartOfAccountIDAPFreight",MySqlDbType.Int32);
                prmChartOfAccountIDAPFreight.Value = clsAPLinkConfigDetails.ChartOfAccountIDAPFreight;
                cmd.Parameters.Add(prmChartOfAccountIDAPFreight);

                MySqlParameter prmChartOfAccountIDAPVDeposit = new MySqlParameter("@ChartOfAccountIDAPVDeposit",MySqlDbType.Int32);
                prmChartOfAccountIDAPVDeposit.Value = clsAPLinkConfigDetails.ChartOfAccountIDAPVDeposit;
                cmd.Parameters.Add(prmChartOfAccountIDAPVDeposit);

                MySqlParameter prmChartOfAccountIDAPContra = new MySqlParameter("@ChartOfAccountIDAPContra",MySqlDbType.Int32);
                prmChartOfAccountIDAPContra.Value = clsAPLinkConfigDetails.ChartOfAccountIDAPContra;
                cmd.Parameters.Add(prmChartOfAccountIDAPContra);

                MySqlParameter prmChartOfAccountIDAPLatePayment = new MySqlParameter("@ChartOfAccountIDAPLatePayment",MySqlDbType.Int32);
                prmChartOfAccountIDAPLatePayment.Value = clsAPLinkConfigDetails.ChartOfAccountIDAPLatePayment;
                cmd.Parameters.Add(prmChartOfAccountIDAPLatePayment);

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

				base.ExecuteNonQuery(cmd);
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Ejemplo n.º 20
0
        public string LastTransactionNo()
        {
            try
            {
                string stRetValue = String.Empty;

                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                stRetValue = clsERPConfig.get_LastDebitMemoNo();

                return stRetValue;
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 21
0
		private void AddItemToInventory(long DebitMemoID)
		{

			POReturnDetails clsPOReturnDetails = Details(DebitMemoID);
			ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			POReturnItems clsPOReturnItems = new POReturnItems(base.Connection, base.Transaction);
			ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
			Products clsProduct = new Products(base.Connection, base.Transaction);
			ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

			Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

			//MySqlDataReader myReader = clsPOReturnItems.List(DebitMemoID, "DebitMemoItemID", SortOption.Ascending);
            System.Data.DataTable dt = clsPOReturnItems.ListAsDataTable(DebitMemoID);

            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = Convert.ToInt64(dr["ProductID"]); // myReader.GetInt64("ProductID");
                int intProductUnitID = Convert.ToInt16(dr["ProductUnitID"]); // myReader.GetInt16("ProductUnitID");

                decimal decItemQuantity = Convert.ToDecimal(dr["Quantity"]); // myReader.GetDecimal("Quantity");
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]); // myReader.GetInt64("VariationMatrixID");
                string strMatrixDescription = dr["MatrixDescription"].ToString(); //  "" + myReader["MatrixDescription"].ToString();
                string strProductCode = dr["ProductCode"].ToString(); // "" + myReader["ProductCode"].ToString();
                string strProductUnitCode = dr["ProductUnitCode"].ToString(); // "" + myReader["ProductUnitCode"].ToString();
                decimal decUnitCost = Convert.ToDecimal(dr["UnitCost"]); // myReader.GetDecimal("UnitCost");
                decimal decItemCost = Convert.ToDecimal(dr["Amount"]); // myReader.GetDecimal("Amount");
                decimal decVAT = Convert.ToDecimal(dr["VAT"]); // myReader.GetDecimal("VAT");

				/*******************************************
				 * Subtract from Inventory
				 * ****************************************/
                // clsProduct.SubtractQuantity(ProductID, Quantity);
                // if (VariationMatrixID != 0) { clsProductVariationsMatrix.SubtractQuantity(VariationMatrixID, Quantity);}
                // July 26, 2011: change the above codes to the following
                clsProduct.SubtractQuantity(clsPOReturnDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_PURCHASE_RETURN), DateTime.Now, clsPOReturnDetails.MemoNo, clsPOReturnDetails.PurchaserName);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				InventoryDetails clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsPOReturnDetails.PostingDate;
				clsInventoryDetails.ReferenceNo = clsPOReturnDetails.MemoNo;
				clsInventoryDetails.ContactID = clsPOReturnDetails.SupplierID;
				clsInventoryDetails.ContactCode = clsPOReturnDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
				clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.PReturnQuantity = decQuantity;
                clsInventoryDetails.PReturnCost = decItemCost - decVAT;
                clsInventoryDetails.PReturnVAT = decItemCost;	//Purchase Return with VAT

				clsInventory.Insert(clsInventoryDetails);
			}
		}
Ejemplo n.º 22
0
        private void AddItemToInventory(long pvtDebitMemoID)
        {
            DebitMemoDetails clsDebitMemoDetails = Details(pvtDebitMemoID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            DebitMemoItems clsDebitMemoItems = new DebitMemoItems(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);

            ProductDetails clsProductDetails = new ProductDetails();
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
            MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

            ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;
            ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsDebitMemoItems.ListAsDataTable(pvtDebitMemoID, SortField: "DebitMemoItemID", SortOrder: SortOption.Ascending);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID = Convert.ToInt64(dr["ProductID"]);
                int intProductUnitID = Convert.ToInt16(dr["ProductUnitID"]);

                decimal decItemQuantity = Convert.ToDecimal(dr["Quantity"]);
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]);
                string strMatrixDescription = dr["MatrixDescription"].ToString();
                string strProductCode = dr["ProductCode"].ToString();
                string strProductUnitCode = dr["ProductUnitCode"].ToString();
                decimal decNewUnitCost = Convert.ToDecimal(dr["UnitCost"]);
                decimal decAmount = Convert.ToDecimal(dr["Amount"]);
                //decimal decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                //decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                //decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                clsProductDetails = clsProduct.Details1(clsDebitMemoDetails.BranchID, lngProductID);
                /*******************************************
				 * Add in the Purchase Price History based on Debit Memo
				 * ****************************************/
                // Update ProductPackagePriceHistory first to get the history
                clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                clsProductPackagePriceHistoryDetails.UID = clsDebitMemoDetails.PurchaserID;
                clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                clsProductPackagePriceHistoryDetails.PurchasePrice = decNewUnitCost * (decItemQuantity / decQuantity);
                clsProductPackagePriceHistoryDetails.Price = -1;
                clsProductPackagePriceHistoryDetails.VAT = -1;
                clsProductPackagePriceHistoryDetails.EVAT = -1;
                clsProductPackagePriceHistoryDetails.LocalTax = -1;
                clsProductPackagePriceHistoryDetails.Remarks = "Based on DebitMemo #: " + clsDebitMemoDetails.MemoNo;
                clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);

                /*******************************************
                 * Subtract from Inventory : Remove this since this is a Debit Memo
                 * ****************************************/
                //clsProduct.SubtractQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.SubtractQuantity(lngVariationMatrixID, decQuantity);
                //}

                /*******************************************
				 * Update Purchasing Information
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsDebitMemoDetails.SupplierID, iBaseUnitID, (decItemQuantity * decNewUnitCost) / decQuantity);
                }
                clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsDebitMemoDetails.SupplierID, intProductUnitID, decNewUnitCost);

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                InventoryDetails clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate = clsDebitMemoDetails.PostingDate;
                clsInventoryDetails.ReferenceNo = clsDebitMemoDetails.MemoNo;
                clsInventoryDetails.ContactID = clsDebitMemoDetails.SupplierID;
                clsInventoryDetails.ContactCode = clsDebitMemoDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.PDebitQuantity = decQuantity;
                clsInventoryDetails.PDebitCost = decAmount - decVAT;
                clsInventoryDetails.PDebitVAT = decAmount;

                clsInventory.Insert(clsInventoryDetails);

            }
        }
Ejemplo n.º 23
0
		private void SubtractItemToInventory(long SOID)
		{

			SODetails clsSODetails = Details(SOID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            SOItem clsSOItem = new SOItem(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
            MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);
			InventoryDetails clsInventoryDetails;

            //MatrixPackagePriceHistoryDetails clsMatrixPackagePriceHistoryDetails;
            //ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

            System.Data.DataTable dt = clsSOItem.ListAsDataTable(SOID, "SOItemID", SortOption.Ascending);
            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = long.Parse(dr["ProductID"].ToString());
                int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string strProductCode = "" + dr["ProductCode"].ToString();
                decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                ///*******************************************
                // * Add in the Sales Price History
                // * ****************************************/
                //if (lngVariationMatrixID != 0)
                //{
                //    // Update MatrixPackagePriceHistory first to get the history
                //    clsMatrixPackagePriceHistoryDetails = new MatrixPackagePriceHistoryDetails();
                //    clsMatrixPackagePriceHistoryDetails.UID = clsSODetails.SellerID;
                //    clsMatrixPackagePriceHistoryDetails.PackageID = clsMatrixPackage.GetPackageID(lngVariationMatrixID, intProductUnitID);
                //    clsMatrixPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsMatrixPackagePriceHistoryDetails.Price = decUnitCost;
                //    clsMatrixPackagePriceHistoryDetails.PurchasePrice = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.VAT = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.EVAT = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.LocalTax = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.Remarks = "Based on SO #: " + clsSODetails.SONo;
                //    MatrixPackagePriceHistory clsMatrixPackagePriceHistory = new MatrixPackagePriceHistory(base.Connection, base.Transaction);
                //    clsMatrixPackagePriceHistory.Insert(clsMatrixPackagePriceHistoryDetails);
                //}
                //else
                //{
                //    // Update ProductPackagePriceHistory first to get the history
                //    clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                //    clsProductPackagePriceHistoryDetails.UID = clsSODetails.SellerID;
                //    clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                //    clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsProductPackagePriceHistoryDetails.Price = decUnitCost;
                //    clsProductPackagePriceHistoryDetails.PurchasePrice = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.VAT = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.EVAT = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.LocalTax = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.Remarks = "Based on SO #: " + clsSODetails.SONo;
                //    ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                //    clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);
                //}


				/*******************************************
				 * Subtract to Inventory
				 * ****************************************/
				// clsProduct.SubtractQuantity(lngProductID, decQuantity);
				// if (lngVariationMatrixID != 0) { clsProductVariationsMatrix.SubtractQuantity(lngVariationMatrixID, decQuantity); }
				// July 28, 2011: change the above codes to the following
				clsProduct.SubtractQuantity(clsSODetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_SOLD_WHOLESALE), DateTime.Now, clsSODetails.SONo, clsSODetails.SellerName);

				/*******************************************
				 * Update Selling Information
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdateSellingPrice(lngProductID, lngVariationMatrixID, clsSODetails.CustomerID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity, -1, -1, -1,- 1, -1); // Price should be the sugegsted selling price
                }
                clsProduct.UpdateSellingWSPrice(lngProductID, lngVariationMatrixID, clsSODetails.CustomerID, intProductUnitID, decUnitCost); // WS Price should be the unit cost


				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsSODetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsSODetails.SONo;
				clsInventoryDetails.ContactID = clsSODetails.CustomerID;
				clsInventoryDetails.ContactCode = clsSODetails.CustomerCode;
				clsInventoryDetails.ProductID = lngProductID;
				clsInventoryDetails.ProductCode = strProductCode;
				clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
				clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.SoldQuantity = decQuantity;
				clsInventoryDetails.SoldCost = decItemCost - decVAT;
				clsInventoryDetails.SoldVAT = decItemCost;	// Sales Cost with VAT

				clsInventory.Insert(clsInventoryDetails);
			}

		}
Ejemplo n.º 24
0
		private void IssueGRN()
		{
			DateTime DeliveryDate = Convert.ToDateTime(txtDeliveryDate.Text);

			ERPConfig clsERPConfig = new ERPConfig();
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();
			clsERPConfig.CommitAndDispose();
			
			if (clsERPConfigDetails.PostingDateFrom <= DeliveryDate && clsERPConfigDetails.PostingDateTo >= DeliveryDate)
			{
                Int64 WBranchTransferID = Convert.ToInt64(lblWBranchTransferID.Text);
				string ReceivedBy = txtReceivedBy.Text;

				WBranchTransfer clsWBranchTransfer = new WBranchTransfer();
				clsWBranchTransfer.IssueGRN(WBranchTransferID, ReceivedBy, DeliveryDate);
				clsWBranchTransfer.CommitAndDispose();

				string stParam = "?task=" + Common.Encrypt("list",Session.SessionID) + "&WBranchTransferID=" + Common.Encrypt(WBranchTransferID.ToString(),Session.SessionID);	
				Response.Redirect("Default.aspx" + stParam);
			}
			else
			{
				string stScript = "<Script>";
				stScript += "window.alert('Sorry you cannot post using the delivery date: " + txtDeliveryDate.Text + ". Please enter an allowable posting date.')";
				stScript += "</Script>";
				Response.Write(stScript);	
			}
		}
Ejemplo n.º 25
0
        public long Insert(DebitMemoDetails Details)
        {
            try
            {
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                APLinkConfigDetails clsAPLinkConfigDetails = clsERPConfig.APLinkDetails();

                string SQL = "INSERT INTO tblPODebitMemo (" +
                                "MemoNo, " +
                                "MemoDate, " +
                                "SupplierID, " +
                                "SupplierCode, " +
                                "SupplierContact, " +
                                "SupplierAddress, " +
                                "SupplierTelephoneNo, " +
                                "SupplierModeOfTerms, " +
                                "SupplierTerms, " +
                                "RequiredPostingDate, " +
                                "BranchID, " +
                                "PurchaserID, " +
                                "PurchaserName, " +
                                "POReturnStatus, " +
                                "DebitMemoStatus, " +
                                "Remarks, " +
                                "ChartOfAccountIDAPTracking, " +
                                "ChartOfAccountIDAPBills, " +
                                "ChartOfAccountIDAPFreight, " +
                                "ChartOfAccountIDAPVDeposit, " +
                                "ChartOfAccountIDAPContra, " +
                                "ChartOfAccountIDAPLatePayment" +
                            ") VALUES (" +
                                "@MemoNo, " +
                                "@MemoDate, " +
                                "@SupplierID, " +
                                "@SupplierCode, " +
                                "@SupplierContact, " +
                                "@SupplierAddress, " +
                                "@SupplierTelephoneNo, " +
                                "@SupplierModeOfTerms, " +
                                "@SupplierTerms, " +
                                "@RequiredPostingDate, " +
                                "@BranchID, " +
                                "@PurchaserID, " +
                                "@PurchaserName, " +
                                "@POReturnStatus, " +
                                "@DebitMemoStatus, " +
                                "@Remarks, " +
                                "@ChartOfAccountIDAPTracking, " +
                                "@ChartOfAccountIDAPBills, " +
                                "@ChartOfAccountIDAPFreight, " +
                                "@ChartOfAccountIDAPVDeposit, " +
                                "@ChartOfAccountIDAPContra, " +
                                "@ChartOfAccountIDAPLatePayment" +
                            ");";

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

                cmd.Parameters.AddWithValue("@MemoNo", Details.MemoNo);
                cmd.Parameters.AddWithValue("@MemoDate", Details.MemoDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@SupplierID", Details.SupplierID);
                cmd.Parameters.AddWithValue("@SupplierCode", Details.SupplierCode);
                cmd.Parameters.AddWithValue("@SupplierContact", Details.SupplierContact);
                cmd.Parameters.AddWithValue("@SupplierAddress", Details.SupplierAddress);
                cmd.Parameters.AddWithValue("@SupplierTelephoneNo", Details.SupplierTelephoneNo);
                cmd.Parameters.AddWithValue("@SupplierModeOfTerms", Details.SupplierModeOfTerms);
                cmd.Parameters.AddWithValue("@SupplierTerms", Details.SupplierTerms);
                cmd.Parameters.AddWithValue("@RequiredPostingDate", Details.RequiredPostingDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchID", Details.BranchID);
                cmd.Parameters.AddWithValue("@PurchaserID", Details.PurchaserID);
                cmd.Parameters.AddWithValue("@PurchaserName", Details.PurchaserName);
                cmd.Parameters.AddWithValue("@POReturnStatus", POReturnStatus.Posted.ToString("d"));
                cmd.Parameters.AddWithValue("@DebitMemoStatus", Details.DebitMemoStatus.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPTracking", clsAPLinkConfigDetails.ChartOfAccountIDAPTracking);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPBills", clsAPLinkConfigDetails.ChartOfAccountIDAPBills);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPFreight", clsAPLinkConfigDetails.ChartOfAccountIDAPFreight);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPVDeposit", clsAPLinkConfigDetails.ChartOfAccountIDAPVDeposit);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPContra", clsAPLinkConfigDetails.ChartOfAccountIDAPContra);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPLatePayment", clsAPLinkConfigDetails.ChartOfAccountIDAPLatePayment);

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

                return iID;
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 26
0
		private void AddItemToInventory(long ClosingID)
		{

			ClosingDetails clsClosingDetails = Details(ClosingID);
			ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			ClosingItem clsClosingItem = new ClosingItem(base.Connection, base.Transaction);
			ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
			Products clsProduct = new Products(base.Connection, base.Transaction);
			ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

			MySqlDataReader myReader = clsClosingItem.List(ClosingID, "ClosingItemID", SortOption.Ascending);

			while (myReader.Read())
			{
                long lngProductID = myReader.GetInt64("ProductID");
				int intProductUnitID = myReader.GetInt16("ProductUnitID");

				decimal decItemQuantity = myReader.GetDecimal("Quantity");
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngMatrixID = myReader.GetInt64("VariationMatrixID");
				string strMatrixDescription = "" + myReader["MatrixDescription"].ToString();
				string strProductCode = "" + myReader["ProductCode"].ToString();
				decimal decUnitCost = myReader.GetDecimal("UnitCost");
				decimal decItemCost = myReader.GetDecimal("Amount");
				decimal decVAT = myReader.GetDecimal("VAT");

				/*******************************************
				 * Update Purchasing Information
				 * ****************************************/
                clsProduct.UpdatePurchasing(lngProductID, lngMatrixID, clsClosingDetails.SupplierID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity);

                ///*******************************************
                // * Add to Inventory
                // * ****************************************/
                //clsProduct.AddQuantity(ProductID, Quantity);
                //if (VariationMatrixID != 0)
                //{ clsProductVariationsMatrix.AddQuantity(VariationMatrixID, Quantity);}
                // July 26, 2011: change the above codes to the following
                clsProduct.AddQuantity(clsClosingDetails.BranchID, lngProductID, lngMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_PURCHASE) + " @ " + decUnitCost.ToString("#,##0.#0"), DateTime.Now, clsClosingDetails.ClosingNo, clsClosingDetails.TransferredByID.ToString());

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				InventoryDetails clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsClosingDetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsClosingDetails.ClosingNo;
				clsInventoryDetails.ContactID = clsClosingDetails.SupplierID;
				clsInventoryDetails.ContactCode = clsClosingDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
				clsInventoryDetails.ProductCode = strProductCode;
				clsInventoryDetails.VariationMatrixID = lngMatrixID;
				clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.ClosingQuantity = decQuantity;
				clsInventoryDetails.ClosingCost = decItemCost - decVAT;
				clsInventoryDetails.ClosingVAT = decItemCost;	// Closing Cost with VAT

				clsInventory.Insert(clsInventoryDetails);

			}
			myReader.Close();

		}
Ejemplo n.º 27
0
        public void Update(DebitMemoDetails Details)
        {
            try
            {
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                APLinkConfigDetails clsAPLinkConfigDetails = clsERPConfig.APLinkDetails();

                string SQL = "UPDATE tblPODebitMemo SET " +
                                "MemoNo				=	@MemoNo, " +
                                "MemoDate				=	@MemoDate, " +
                                "SupplierID				=	@SupplierID, " +
                                "SupplierCode			=	@SupplierCode, " +
                                "SupplierContact		=	@SupplierContact, " +
                                "SupplierAddress		=	@SupplierAddress, " +
                                "SupplierTelephoneNo	=	@SupplierTelephoneNo, " +
                                "SupplierModeOfTerms	=	@SupplierModeOfTerms, " +
                                "SupplierTerms			=	@SupplierTerms, " +
                                "RequiredPostingDate	=	@RequiredPostingDate, " +
                                "BranchID				=	@BranchID, " +
                                "PurchaserID			=	@PurchaserID, " +
                                "PurchaserName          =   @PurchaserName, " +
                                "Remarks                =   @Remarks, " +
                                "ChartOfAccountIDAPTracking     = @ChartOfAccountIDAPTracking, " +
                                "ChartOfAccountIDAPBills        = @ChartOfAccountIDAPBills, " +
                                "ChartOfAccountIDAPFreight      = @ChartOfAccountIDAPFreight, " +
                                "ChartOfAccountIDAPVDeposit     = @ChartOfAccountIDAPVDeposit, " +
                                "ChartOfAccountIDAPContra       = @ChartOfAccountIDAPContra, " +
                                "ChartOfAccountIDAPLatePayment  = @ChartOfAccountIDAPLatePayment " +
                            "WHERE DebitMemoID = @DebitMemoID;";

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

                cmd.Parameters.AddWithValue("@MemoNo", Details.MemoNo);
                cmd.Parameters.AddWithValue("@MemoDate", Details.MemoDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@SupplierID", Details.SupplierID);
                cmd.Parameters.AddWithValue("@SupplierCode", Details.SupplierCode);
                cmd.Parameters.AddWithValue("@SupplierContact", Details.SupplierContact);
                cmd.Parameters.AddWithValue("@SupplierAddress", Details.SupplierAddress);
                cmd.Parameters.AddWithValue("@SupplierTelephoneNo", Details.SupplierTelephoneNo);
                cmd.Parameters.AddWithValue("@SupplierModeOfTerms", Details.SupplierModeOfTerms);
                cmd.Parameters.AddWithValue("@SupplierTerms", Details.SupplierTerms);
                cmd.Parameters.AddWithValue("@RequiredPostingDate", Details.RequiredPostingDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchID", Details.BranchID);
                cmd.Parameters.AddWithValue("@PurchaserID", Details.PurchaserID);
                cmd.Parameters.AddWithValue("@PurchaserName", Details.PurchaserName);
                cmd.Parameters.AddWithValue("@POReturnStatus", POReturnStatus.Posted.ToString("d"));
                cmd.Parameters.AddWithValue("@DebitMemoStatus", Details.DebitMemoStatus.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPTracking", clsAPLinkConfigDetails.ChartOfAccountIDAPTracking);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPBills", clsAPLinkConfigDetails.ChartOfAccountIDAPBills);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPFreight", clsAPLinkConfigDetails.ChartOfAccountIDAPFreight);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPVDeposit", clsAPLinkConfigDetails.ChartOfAccountIDAPVDeposit);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPContra", clsAPLinkConfigDetails.ChartOfAccountIDAPContra);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDAPLatePayment", clsAPLinkConfigDetails.ChartOfAccountIDAPLatePayment);
                cmd.Parameters.AddWithValue("@DebitMemoID", Details.DebitMemoID);

                base.ExecuteNonQuery(cmd);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 28
0
        public void Update(CreditMemoDetails Details)
        {
            try
            {
                ERPConfig           clsERPConfig           = new ERPConfig(base.Connection, base.Transaction);
                ARLinkConfigDetails clsARLinkConfigDetails = clsERPConfig.ARLinkDetails();

                string SQL = "UPDATE tblSOCreditMemo SET " +
                             "CNNo				=	@CNNo, "+
                             "CNDate				=	@CNDate, "+
                             "CustomerID				=	@CustomerID, "+
                             "CustomerCode			=	@CustomerCode, "+
                             "CustomerContact		=	@CustomerContact, "+
                             "CustomerAddress		=	@CustomerAddress, "+
                             "CustomerTelephoneNo	=	@CustomerTelephoneNo, "+
                             "CustomerModeOfTerms	=	@CustomerModeOfTerms, "+
                             "CustomerTerms			=	@CustomerTerms, "+
                             "RequiredPostingDate	=	@RequiredPostingDate, "+
                             "BranchID				=	@BranchID, "+
                             "SellerID			=	@SellerID, "+
                             "SellerName          =   @SellerName, " +
                             "Remarks                =   @Remarks, " +
                             "ChartOfAccountIDARTracking     = @ChartOfAccountIDARTracking, " +
                             "ChartOfAccountIDARBills        = @ChartOfAccountIDARBills, " +
                             "ChartOfAccountIDARFreight      = @ChartOfAccountIDARFreight, " +
                             "ChartOfAccountIDARVDeposit     = @ChartOfAccountIDARVDeposit, " +
                             "ChartOfAccountIDARContra       = @ChartOfAccountIDARContra, " +
                             "ChartOfAccountIDARLatePayment  = @ChartOfAccountIDARLatePayment " +
                             "WHERE CreditMemoID = @CreditMemoID;";



                MySqlCommand cmd = new MySqlCommand();


                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@CNNo", Details.CNNo);
                cmd.Parameters.AddWithValue("@CNDate", Details.CNDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@CustomerID", Details.CustomerID);
                cmd.Parameters.AddWithValue("@CustomerCode", Details.CustomerCode);
                cmd.Parameters.AddWithValue("@CustomerContact", Details.CustomerContact);
                cmd.Parameters.AddWithValue("@CustomerAddress", Details.CustomerAddress);
                cmd.Parameters.AddWithValue("@CustomerTelephoneNo", Details.CustomerTelephoneNo);
                cmd.Parameters.AddWithValue("@CustomerModeOfTerms", Details.CustomerModeOfTerms);
                cmd.Parameters.AddWithValue("@CustomerTerms", Details.CustomerTerms);
                cmd.Parameters.AddWithValue("@RequiredPostingDate", Details.RequiredPostingDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchID", Details.BranchID);
                cmd.Parameters.AddWithValue("@SellerID", Details.SellerID);
                cmd.Parameters.AddWithValue("@SellerName", Details.SellerName);
                cmd.Parameters.AddWithValue("@SOReturnStatus", SOReturnStatus.Posted.ToString("d"));
                cmd.Parameters.AddWithValue("@CreditMemoStatus", Details.CreditMemoStatus.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARTracking", clsARLinkConfigDetails.ChartOfAccountIDARTracking);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARBills", clsARLinkConfigDetails.ChartOfAccountIDARBills);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARFreight", clsARLinkConfigDetails.ChartOfAccountIDARFreight);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARVDeposit", clsARLinkConfigDetails.ChartOfAccountIDARVDeposit);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARContra", clsARLinkConfigDetails.ChartOfAccountIDARContra);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARLatePayment", clsARLinkConfigDetails.ChartOfAccountIDARLatePayment);
                cmd.Parameters.AddWithValue("@CreditMemoID", Details.CreditMemoID);

                base.ExecuteNonQuery(cmd);
            }

            catch (Exception ex)
            {
                {
                }

                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 29
0
        private void IssueGRN()
        {
            DateTime DeliveryDate = Convert.ToDateTime(txtDeliveryDate.Text);

            ERPConfig clsERPConfig = new ERPConfig();
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();
            clsERPConfig.CommitAndDispose();

            if (clsERPConfigDetails.PostingDateFrom <= DeliveryDate && clsERPConfigDetails.PostingDateTo >= DeliveryDate)
            {
                long SOID = Convert.ToInt64(lblSOID.Text);
                string CustomerDRNo = txtCustomerDRNo.Text;

                SO clsSO = new SO();
                clsSO.IssueGRN(SOID, CustomerDRNo, DeliveryDate);
                clsSO.CommitAndDispose();

                string stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&soid=" + Common.Encrypt(SOID.ToString(), Session.SessionID);
                Response.Redirect("Default.aspx" + stParam);
            }
            else
            {
                string stScript = "<Script>";
                stScript += "window.alert('Sorry you cannot post using the delivery date: " + txtDeliveryDate.Text + ". Please enter an allowable posting date.')";
                stScript += "</Script>";
                Response.Write(stScript);
            }
        }
Ejemplo n.º 30
0
        public long Insert(CreditMemoDetails Details)
        {
            try
            {
                ERPConfig           clsERPConfig           = new ERPConfig(base.Connection, base.Transaction);
                ARLinkConfigDetails clsARLinkConfigDetails = clsERPConfig.ARLinkDetails();

                string SQL = "INSERT INTO tblSOCreditMemo (" +
                             "CNNo, " +
                             "CNDate, " +
                             "CustomerID, " +
                             "CustomerCode, " +
                             "CustomerContact, " +
                             "CustomerAddress, " +
                             "CustomerTelephoneNo, " +
                             "CustomerModeOfTerms, " +
                             "CustomerTerms, " +
                             "RequiredPostingDate, " +
                             "BranchID, " +
                             "SellerID, " +
                             "SellerName, " +
                             "SOReturnStatus, " +
                             "CreditMemoStatus, " +
                             "Remarks, " +
                             "ChartOfAccountIDARTracking, " +
                             "ChartOfAccountIDARBills, " +
                             "ChartOfAccountIDARFreight, " +
                             "ChartOfAccountIDARVDeposit, " +
                             "ChartOfAccountIDARContra, " +
                             "ChartOfAccountIDARLatePayment" +
                             ") VALUES (" +
                             "@CNNo, " +
                             "@CNDate, " +
                             "@CustomerID, " +
                             "@CustomerCode, " +
                             "@CustomerContact, " +
                             "@CustomerAddress, " +
                             "@CustomerTelephoneNo, " +
                             "@CustomerModeOfTerms, " +
                             "@CustomerTerms, " +
                             "@RequiredPostingDate, " +
                             "@BranchID, " +
                             "@SellerID, " +
                             "@SellerName, " +
                             "@SOReturnStatus, " +
                             "@CreditMemoStatus, " +
                             "@Remarks, " +
                             "@ChartOfAccountIDARTracking, " +
                             "@ChartOfAccountIDARBills, " +
                             "@ChartOfAccountIDARFreight, " +
                             "@ChartOfAccountIDARVDeposit, " +
                             "@ChartOfAccountIDARContra, " +
                             "@ChartOfAccountIDARLatePayment" +
                             ");";



                MySqlCommand cmd = new MySqlCommand();


                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@CNNo", Details.CNNo);
                cmd.Parameters.AddWithValue("@CNDate", Details.CNDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@CustomerID", Details.CustomerID);
                cmd.Parameters.AddWithValue("@CustomerCode", Details.CustomerCode);
                cmd.Parameters.AddWithValue("@CustomerContact", Details.CustomerContact);
                cmd.Parameters.AddWithValue("@CustomerAddress", Details.CustomerAddress);
                cmd.Parameters.AddWithValue("@CustomerTelephoneNo", Details.CustomerTelephoneNo);
                cmd.Parameters.AddWithValue("@CustomerModeOfTerms", Details.CustomerModeOfTerms);
                cmd.Parameters.AddWithValue("@CustomerTerms", Details.CustomerTerms);
                cmd.Parameters.AddWithValue("@RequiredPostingDate", Details.RequiredPostingDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@BranchID", Details.BranchID);
                cmd.Parameters.AddWithValue("@SellerID", Details.SellerID);
                cmd.Parameters.AddWithValue("@SellerName", Details.SellerName);
                cmd.Parameters.AddWithValue("@SOReturnStatus", SOReturnStatus.Posted.ToString("d"));
                cmd.Parameters.AddWithValue("@CreditMemoStatus", Details.CreditMemoStatus.ToString("d"));
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARTracking", clsARLinkConfigDetails.ChartOfAccountIDARTracking);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARBills", clsARLinkConfigDetails.ChartOfAccountIDARBills);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARFreight", clsARLinkConfigDetails.ChartOfAccountIDARFreight);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARVDeposit", clsARLinkConfigDetails.ChartOfAccountIDARVDeposit);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARContra", clsARLinkConfigDetails.ChartOfAccountIDARContra);
                cmd.Parameters.AddWithValue("@ChartOfAccountIDARLatePayment", clsARLinkConfigDetails.ChartOfAccountIDARLatePayment);

                base.ExecuteNonQuery(cmd);

                SQL = "SELECT LAST_INSERT_ID();";

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

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

                Int64 iID = 0;

                while (myReader.Read())
                {
                    iID = myReader.GetInt64(0);
                }

                myReader.Close();

                return(iID);
            }

            catch (Exception ex)
            {
                {
                }

                throw base.ThrowException(ex);
            }
        }
        private string CloseInventory()
        {
            string strRetValue = "";

            try
            {
                DateTime DeliveryDate = Convert.ToDateTime(txtClosingDate.Text);

                ERPConfig clsERPConfig = new ERPConfig();
                ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

                if (clsERPConfigDetails.PostingDateFrom <= DeliveryDate && clsERPConfigDetails.PostingDateTo >= DeliveryDate)
                {
                    string strReferenceNo = Constants.CLOSE_INVENTORY_CODE + CompanyDetails.BECompanyCode + DateTime.Now.Year.ToString() + clsERPConfig.get_LastClosingNo();

                    AccessUserDetails clsAccessUserDetails = (AccessUserDetails)Session["AccessUserDetails"];

                    ProductInventories clsProductInventories = new ProductInventories(clsERPConfig.Connection, clsERPConfig.Transaction);
                    clsProductInventories.CloseInventoryByProductGroup(int.Parse(cboBranch.SelectedItem.Value), clsAccessUserDetails.UID, DateTime.Parse(txtClosingDate.Text), strReferenceNo, long.Parse(cboProductGroup.SelectedItem.Value), cboProductGroup.SelectedItem.Text);

                    Products clsProducts = new Products(clsERPConfig.Connection, clsERPConfig.Transaction);
                    clsProducts.LockUnlockForSellingByProductGroup(int.Parse(cboBranch.SelectedItem.Value), long.Parse(cboProductGroup.SelectedItem.Value), false);

                    clsERPConfig.CommitAndDispose();
                    strRetValue = strReferenceNo;
                }
                else
                {
                    clsERPConfig.CommitAndDispose();
                    string stScript = "<Script>";
                    stScript += "window.alert('Sorry you cannot close using the closing date: " + txtClosingDate.Text + ". Please enter an allowable posting date.')";
                    stScript += "</Script>";
                    Response.Write(stScript);
                }
            }
            catch (Exception ex)
            {
                string stScript = "<Script>";
                stScript += "window.alert('An error has occured while closing the inventory. Details:' " + ex.Message + ")";
                stScript += "</Script>";
                Response.Write(stScript);
            }
            return strRetValue;
        }
Ejemplo n.º 32
0
        private void AddItemToInventory(long CreditMemoID)
        {

            CreditMemoDetails clsCreditMemoDetails = Details(CreditMemoID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            CreditMemoItems clsCreditMemoItems = new CreditMemoItems(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsCreditMemoItems.ListAsDataTable(CreditMemoID);

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                long lngProductID = long.Parse(dr["ProductID"].ToString());
                int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string strProductCode = "" + dr["ProductCode"].ToString();
                decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

                /*******************************************
                 * Do not Add to Inventory coz this is a Debit Memo and no effect on inventory
                 * ****************************************/

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                InventoryDetails clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate = clsCreditMemoDetails.PostingDate;
                clsInventoryDetails.ReferenceNo = clsCreditMemoDetails.CNNo;
                clsInventoryDetails.ContactID = clsCreditMemoDetails.CustomerID;
                clsInventoryDetails.ContactCode = clsCreditMemoDetails.CustomerCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.SCreditQuantity = decQuantity;
                clsInventoryDetails.SCreditCost = decItemCost - decVAT;
                clsInventoryDetails.SCreditVAT = decItemCost;	//Sales Return with VAT

                clsInventory.Insert(clsInventoryDetails);

            }
            //myReader.Close();

        }