Exemple #1
0
        public static DataTable InsertPurchaseMaster(ProductPurchaseInfo objProductPurchaseInfo)
        {
            ISalesPOSDBManager dbManager = new SalesPOSDBManager();
            DataTable          dt        = new DataTable();

            try
            {
                dbManager.Open();
                IDbDataParameter[] param = SalesPOSDBManagerFactory.GetParameters(dbManager.ProviderType, 5);

                param[0] = dbManager.getparam("@TransactionDate", objProductPurchaseInfo.TransactionDate);
                param[1] = dbManager.getparam("@MemoNo", objProductPurchaseInfo.MemoNo);
                param[2] = dbManager.getparam("@CreatedBy", objProductPurchaseInfo.CreatedBy);
                param[3] = dbManager.getparam("@SupplierCode", objProductPurchaseInfo.SupplierID);
                param[4] = dbManager.getparam("@TotalAmount", Convert.ToDecimal(objProductPurchaseInfo.TotalPrice));
                IDbCommand cmd = dbManager.getCommand(CommandType.StoredProcedure, "dbo.[insert_purchase_master]", param);
                dt = dbManager.GetDataTable(cmd);
            }
            catch (Exception ex)
            {
                //return false;
            }
            finally
            {
                dbManager.Dispose();
            }
            return(dt);
        }
Exemple #2
0
        public static DataTable InsertPurchaseMaster_For_SalesReturn(ProductPurchaseInfo objProductPurchaseInfo)
        {
            ISalesPOSDBManager dbManager = new SalesPOSDBManager();
            DataTable          dt        = new DataTable();

            try
            {
                dbManager.Open();
                IDbDataParameter[] param = SalesPOSDBManagerFactory.GetParameters(dbManager.ProviderType, 10);

                param[0] = dbManager.getparam("@PurchaseDate", objProductPurchaseInfo.PurchaseDate);
                param[1] = dbManager.getparam("@MemoNo", objProductPurchaseInfo.MemoNo);
                param[2] = dbManager.getparam("@TotalAmount", objProductPurchaseInfo.TotalAmount);
                param[3] = dbManager.getparam("@TotalPaid", objProductPurchaseInfo.TotalPaid);
                param[4] = dbManager.getparam("@SupplierAccountNo", objProductPurchaseInfo.SupplierAccountNo);
                param[5] = dbManager.getparam("@CreatedBy", objProductPurchaseInfo.CreatedBy);
                param[6] = dbManager.getparam("@pk_code", "");
                param[7] = dbManager.getparam("@TerminalID", bllUtility.LoggedInSystemInformation.TerminalID.ToString());
                param[8] = dbManager.getparam("@TransactionType", objProductPurchaseInfo.TransactionType);
                param[9] = dbManager.getparam("@PurchaseID", objProductPurchaseInfo.PurchaseID);

                IDbCommand cmd = dbManager.getCommand(CommandType.StoredProcedure, "dbo.USP_PurchaseMasterInfo_Add_From_Sales", param);
                dt = dbManager.GetDataTable(cmd);
            }
            catch (Exception ex)
            {
                //return false;
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                dbManager.Dispose();
            }
            return(dt);
        }
Exemple #3
0
        public void LogPurchaseComplete(ProductPurchaseInfo purchaseInfo)
        {
            var evtData = new EventTelemetry("In App Purchase Complete");

            evtData.Properties.Add("ProductId", purchaseInfo.ProductId);
            evtData.Properties.Add("ProductName", purchaseInfo.ProductName);
            evtData.Properties.Add("CommerceEngine", purchaseInfo.CommerceEngine);
            evtData.Properties.Add("CurrentMarket", purchaseInfo.CurrentMarket);
            evtData.Properties.Add("Currency", purchaseInfo.Currency);
            evtData.Properties.Add("Price", purchaseInfo.Price.ToString("N2"));

            _client.TrackEvent(evtData);
        }
        private async void FulfillProduct(ProductPurchaseInfo info)
        {
            if (!IsLocallyFulfilled(info, info.tempTransactionId))
            {
                GrantFeatureLocally(info, info.tempTransactionId);
            }

            try
            {
                FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync(info.productId, info.tempTransactionId);

                switch (result)
                {
                case FulfillmentResult.Succeeded:
                    info.numFulfillments++;
                    rootPage.NotifyUser(info.nameRun.Text + " was fulfilled. You are now able to buy another one.", NotifyType.StatusMessage);
                    break;

                case FulfillmentResult.NothingToFulfill:
                    rootPage.NotifyUser("There is nothing to fulfill. You must purchase " + info.nameRun.Text + " before it can be fulfilled.", NotifyType.StatusMessage);
                    break;

                case FulfillmentResult.PurchasePending:
                    rootPage.NotifyUser("Purchase hasn't completed yet. Wait and try again.", NotifyType.StatusMessage);
                    break;

                case FulfillmentResult.PurchaseReverted:
                    rootPage.NotifyUser("Purchase was reverted before fulfillment.", NotifyType.StatusMessage);
                    // Since the user's purchase was revoked, they got their money back.
                    // You may want to revoke the user's access to the consumable content that was granted.
                    break;

                case FulfillmentResult.ServerError:
                    rootPage.NotifyUser("There was an error when fulfilling.", NotifyType.StatusMessage);
                    break;
                }
            }
            catch (Exception)
            {
                rootPage.NotifyUser("There was an error when fulfilling.", NotifyType.ErrorMessage);
            }
            UpdateStatistics();
        }
Exemple #5
0
        public async Task PurchaseProduct(string productId)
        {
            try
            {
                // Kick off purchase; don't ask for a receipt when it returns
                var purchaseResult = await CurrentApp.RequestProductPurchaseAsync(productId);

                await GetListings();

                var    productInfo = _listings.ProductListings[productId];
                double price       = 0;
                if (!double.TryParse(productInfo.FormattedPrice, System.Globalization.NumberStyles.Currency, System.Globalization.CultureInfo.CurrentUICulture, out price))
                {
                    price = 0;
                }
                var purchaseInfo = new ProductPurchaseInfo()
                {
                    ProductId      = productId,
                    ProductName    = productInfo.Name,
                    CommerceEngine = "Windows Phone Store",
                    CurrentMarket  = _listings.CurrentMarket,
                    Price          = price,
                    Currency       = System.Globalization.CultureInfo.CurrentUICulture.NumberFormat.CurrencySymbol
                };

                _log.LogMessage(productId + " Purchased");
                _log.LogPurchaseComplete(purchaseInfo);

                // Now that purchase is done, give the user the goods they paid for
                // (DoFulfillment is defined later)
                await DoFulfillment();
            }
            catch (Exception ex)
            {
                // When the user does not complete the purchase (e.g. cancels or navigates back from the Purchase Page), an exception with an HRESULT of E_FAIL is expected.
                _log.LogException(ex, productId + " Purchase Aborted");
            }
        }
        private async void BuyProduct(ProductPurchaseInfo info)
        {
            rootPage.NotifyUser("Buying " + info.nameRun.Text + "...", NotifyType.StatusMessage);
            try
            {
                PurchaseResults purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync(info.productId);

                switch (purchaseResults.Status)
                {
                case ProductPurchaseStatus.Succeeded:
                    info.numPurchases++;
                    info.tempTransactionId = purchaseResults.TransactionId;
                    rootPage.NotifyUser("You bought " + info.nameRun.Text + ". Transaction Id: " + purchaseResults.TransactionId, NotifyType.StatusMessage);

                    // Normally you would grant the user their content here, and then call currentApp.reportConsumableFulfillment
                    // For demonstration purposes, we leave the purchase unfulfilled.
                    break;

                case ProductPurchaseStatus.NotFulfilled:
                    info.tempTransactionId = purchaseResults.TransactionId;
                    rootPage.NotifyUser("You have an unfulfilled copy of " + info.nameRun.Text + ". Fulfill it before purchasing another one.", NotifyType.StatusMessage);

                    // Normally you would grant the user their content here, and then call currentApp.reportConsumableFulfillment
                    // For demonstration purposes, we leave the purchase unfulfilled.
                    break;

                case ProductPurchaseStatus.NotPurchased:
                    rootPage.NotifyUser(info.nameRun.Text + " was not purchased.", NotifyType.StatusMessage);
                    break;
                }
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Unable to buy " + info.nameRun.Text + ".", NotifyType.ErrorMessage);
            }
            UpdateStatistics();
        }
 private Boolean IsLocallyFulfilled(ProductPurchaseInfo info, Guid transactionId)
 {
     return(info.consumedTransactionIds.Contains(transactionId));
 }
        private void GrantFeatureLocally(ProductPurchaseInfo info, Guid transactionId)
        {
            info.consumedTransactionIds.Add(transactionId);

            // Grant the user their content. You will likely increase some kind of gold/coins/some other asset count.
        }
 private Boolean IsLocallyFulfilled(ProductPurchaseInfo info, Guid transactionId)
 {
     return info.consumedTransactionIds.Contains(transactionId);
 }
        private void GrantFeatureLocally(ProductPurchaseInfo info, Guid transactionId)
        {
            info.consumedTransactionIds.Add(transactionId);

            // Grant the user their content. You will likely increase some kind of gold/coins/some other asset count.
        }
        private async void FulfillProduct(ProductPurchaseInfo info)
        {
            if (!IsLocallyFulfilled(info, info.tempTransactionId))
            {
                GrantFeatureLocally(info, info.tempTransactionId);
            }

            try
            {
                FulfillmentResult result = await CurrentAppSimulator.ReportConsumableFulfillmentAsync(info.productId, info.tempTransactionId);

                switch (result)
                {
                    case FulfillmentResult.Succeeded:
                        info.numFulfillments++;
                        rootPage.NotifyUser(info.nameRun.Text + " was fulfilled. You are now able to buy another one.", NotifyType.StatusMessage);
                        break;
                    case FulfillmentResult.NothingToFulfill:
                        rootPage.NotifyUser("There is nothing to fulfill. You must purchase " + info.nameRun.Text + " before it can be fulfilled.", NotifyType.StatusMessage);
                        break;
                    case FulfillmentResult.PurchasePending:
                        rootPage.NotifyUser("Purchase hasn't completed yet. Wait and try again.", NotifyType.StatusMessage);
                        break;
                    case FulfillmentResult.PurchaseReverted:
                        rootPage.NotifyUser("Purchase was reverted before fulfillment.", NotifyType.StatusMessage);
                        // Since the user's purchase was revoked, they got their money back.
                        // You may want to revoke the user's access to the consumable content that was granted.
                        break;
                    case FulfillmentResult.ServerError:
                        rootPage.NotifyUser("There was an error when fulfilling.", NotifyType.StatusMessage);
                        break;
                }
            }
            catch (Exception)
            {
                rootPage.NotifyUser("There was an error when fulfilling.", NotifyType.ErrorMessage);
            }
            UpdateStatistics();
        }
        private async void BuyProduct(ProductPurchaseInfo info)
        {
            rootPage.NotifyUser("Buying " + info.nameRun.Text + "...", NotifyType.StatusMessage);
            try
            {
                PurchaseResults purchaseResults = await CurrentAppSimulator.RequestProductPurchaseAsync(info.productId);
                switch (purchaseResults.Status)
                {
                    case ProductPurchaseStatus.Succeeded:
                        info.numPurchases++;
                        info.tempTransactionId = purchaseResults.TransactionId;
                        rootPage.NotifyUser("You bought " + info.nameRun.Text + ". Transaction Id: " + purchaseResults.TransactionId, NotifyType.StatusMessage);

                        // Normally you would grant the user their content here, and then call currentApp.reportConsumableFulfillment
                        // For demonstration purposes, we leave the purchase unfulfilled.
                        break;
                    case ProductPurchaseStatus.NotFulfilled:
                        info.tempTransactionId = purchaseResults.TransactionId;
                        rootPage.NotifyUser("You have an unfulfilled copy of " + info.nameRun.Text + ". Fulfill it before purchasing another one.", NotifyType.StatusMessage);

                        // Normally you would grant the user their content here, and then call currentApp.reportConsumableFulfillment
                        // For demonstration purposes, we leave the purchase unfulfilled.
                        break;
                    case ProductPurchaseStatus.NotPurchased:
                        rootPage.NotifyUser(info.nameRun.Text + " was not purchased.", NotifyType.StatusMessage);
                        break;
                }
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Unable to buy " + info.nameRun.Text + ".", NotifyType.ErrorMessage);
            }
            UpdateStatistics();
        }
        private void SaveDate()
        {
            string AccountNo = "";

            if (txtSupplierCode.Text == "")
            {
                AccountNo = "SUP00000000000";
            }
            else
            {
                AccountNo = txtSupplierCode.Text;
            }
            //initialize the purchase information
            ProductPurchaseInfo objProductPurchaseInfo = new ProductPurchaseInfo();

            objProductPurchaseInfo.PurchaseDate      = dtpPurchaseDate.Value.ToString("dd/MM/yyyy");
            objProductPurchaseInfo.MemoNo            = txtMemoNo.Text.Trim();
            objProductPurchaseInfo.TotalAmount       = Convert.ToDouble(lblTotalItemAmount.Text.Trim());
            objProductPurchaseInfo.TotalPaid         = Convert.ToDouble(txtPaid.Text.Trim());
            objProductPurchaseInfo.SupplierAccountNo = txtSupplierCode.Text.Trim();
            objProductPurchaseInfo.CreatedBy         = bllUtility.LoggedInSystemInformation.LoggedUserId;
            objProductPurchaseInfo.TransactionType   = "Purchase";
            int area_id = 1;
            //if (bllUtility.DefaultSettings.Store2Display == "True")
            //{
            //    area_id = 2;
            //}

            //execute the master purchase information & get the purchase no
            DataTable dt         = bllProductPurchase.InsertPurchaseMaster(objProductPurchaseInfo);
            string    purchaseID = dt.Rows[0][0].ToString();

            for (int i = 0; i < dgvPurchaseGrid.Rows.Count; i++)
            {
                //execute purchase master details info...........
                bool chk = bllProductPurchase.InsertPurchaseMasterDetails(purchaseID.Trim(), dgvPurchaseGrid.Rows[i].Cells["ProductID"].Value.ToString().Trim(), dgvPurchaseGrid.Rows[i].Cells["UnitID"].Value.ToString().Trim(), dgvPurchaseGrid.Rows[i].Cells["Quantity"].Value.ToString().Trim(), dgvPurchaseGrid.Rows[i].Cells["TotalPrice"].Value.ToString().Trim(), bllUtility.LoggedInSystemInformation.LoggedUserId.ToString(), dgvPurchaseGrid.Rows[i].Cells["IsExpDate"].Value.ToString(), dgvPurchaseGrid.Rows[i].Cells["ExpireDate"].Value.ToString().Trim(), area_id, dgvPurchaseGrid.Rows[i].Cells["UnitPrice"].Value.ToString().Trim());
            }


            //disable save button
            this.btnSave.Enabled                = false;
            this.btnResetGrid.Enabled           = false;
            this.btnAddToGrid.Enabled           = false;
            this.txtProductID.Enabled           = false;
            this.txtProductName.Enabled         = false;
            this.dgvPurchaseGrid.Enabled        = false;
            this.dgvProductUnitQuantity.Enabled = false;
            //set the purchase ID on the screen text box
            this.txtPurchaseNo.Text = purchaseID;

            //enable print button
            this.btnPrint.Enabled = true;


            /********************************************************
             * Save Purchase Payment
             * *******************************************************/
            //InitializePurchasePaymentInfo();
            //bllProductPurchase.InsertPurchasePayment(objPurchasePaymentInfo);

            /*Account transaction for sales*/
            bllProductSales.InsertAccountTransactionBySystem("Purchase", lblTotalItemAmount.Text, txtPurchaseNo.Text, txtDescription.Text.Replace("'", "").Replace(",", ""), bllUtility.LoggedInSystemInformation.TerminalID.ToString(), AccountNo, bllUtility.LoggedInSystemInformation.LoggedUserId.ToString(), DateTime.Now.ToString("dd/MM/yyyy"), 0);

            if (Convert.ToDouble(txtPaid.Text) > 0)
            {
                bllProductSales.InsertAccountTransactionBySystem("Cash Paid", txtPaid.Text, txtPurchaseNo.Text, txtDescription.Text.Replace("'", "").Replace(",", ""), bllUtility.LoggedInSystemInformation.TerminalID.ToString(), AccountNo, bllUtility.LoggedInSystemInformation.LoggedUserId.ToString(), DateTime.Now.ToString("dd/MM/yyyy"), 0);
            }


            //display successful message
            XtraMessageBox.Show("Successfully Inserted the purchase information");
        }