示例#1
0
        private void ReturnToStoreForQuantityEdit()
        {
            //TODO: finish updating the changed locations
            TransactionMgr transaction = TransactionMgr.ThreadTransactionMgr();

            transaction.BeginTransaction();
            try
            {
                var    pl        = new PalletLocation();
                String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();
                //           pl.ConfirmAllReceived(reference);
                if (gridDetailView.DataSource == null)
                {
                    return;
                }

                foreach (DataRowView drv in gridDetailView.DataSource as DataView)
                {
                    int PalletLocationID         = Convert.ToInt32(drv["PalletLocationID"]);
                    int ProposedPalletLocationID = Convert.ToInt32(drv["ProposedPalletLocationID"]);

                    if (PalletLocationID != ProposedPalletLocationID)
                    {
                        pl.LoadByPrimaryKey(PalletLocationID);
                        if (pl.IsColumnNull("PalletID"))
                        {
                            pl.Confirmed = false;
                            pl.Save();
                        }
                    }
                    else
                    {
                        pl.LoadByPrimaryKey(PalletLocationID);
                        pl.Confirmed = false;
                        pl.Save();
                    }
                }


                var recDoc = new ReceiveDoc();
                recDoc.LoadByReferenceNo(reference);
                recDoc.SetStatusAsReceived(null);
                transaction.CommitTransaction();
                XtraMessageBox.Show("Receipt Returned!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BindFormContents();
            }
            catch (Exception exp)
            {
                transaction.RollbackTransaction();
                XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        private void OnConfirmClicked(object sender, EventArgs e)
        {
            if (BLL.Settings.IsCenter)
            {
                GRV = new CenterCostCalculator();
                GRV.LoadGRV(ReceiptID);
                GRV.CalculateFinalCost();
            }
            else
            {
                GRV = new CostCalculator();
                GRV.LoadGRV(ReceiptID);
                (GRV as CostCalculator).LoadGRVPreviousStock();
                GRV.CalculateFinalCost();
            }
            if (!SetSellingPrice(GRV))
            {
                return;
            }

            TransactionMgr transaction = TransactionMgr.ThreadTransactionMgr();

            try
            {
                transaction.BeginTransaction();
                // This is where we set the Price for the previous Stock
                foreach (CostElement costElement in GRV.CostElements)
                {
                    costElement.PreviousCostDetials.Confirm(CurrentContext.UserId);
                }

                PrintConfirmation(null);
                try
                {
                    CostingService.ConfirmPriceChange(GRV.CostElements, CurrentContext.UserId, ChangeMode.Recieve, ReceiptID.ToString());
                }
                catch (Exception exception)
                {
                    XtraMessageBox.Show(exception.Message);
                    throw exception;
                }
                transaction.CommitTransaction();
                this.LogActivity("Print-SRM", ReceiptID);
            }
            catch (Exception ex)
            {
                transaction.RollbackTransaction();
                XtraMessageBox.Show(ex.Message);
            }
        }
示例#3
0
        private void btnReprintGRV_Click(object sender, EventArgs e)
        {
            TransactionMgr transaction = TransactionMgr.ThreadTransactionMgr();

            try
            {
                transaction.BeginTransaction();
                DataRow dr = gridReceiveView.GetFocusedDataRow();
                int?    receiptConfirmationPrintoutID = Convert.ToInt32(dr["ID"]);
                PrintConfirmation(receiptConfirmationPrintoutID);
                transaction.CommitTransaction();
                this.LogActivity("Reprint", ReceiptID);
            }
            catch (Exception ex)
            {
                transaction.RollbackTransaction();
                XtraMessageBox.Show(ex.Message);
            }
        }
示例#4
0
        private void btnSaveTransaction_Click(object sender, System.EventArgs e)
        {
            TransactionMgr tx = TransactionMgr.ThreadTransactionMgr();

            try
            {
                tx.BeginTransaction();

                this.emps.Save();
                this.prds.Save();

                tx.CommitTransaction();

                BindEmployeesGrid();
                BindProductsGrid();
            }
            catch (Exception)
            {
                tx.RollbackTransaction();
                TransactionMgr.ThreadTransactionMgrReset();
                MessageBox.Show("You need to generate the stored procedures for 'Employees' and 'Products' to be able to save. Use 'SQL_StoredProcs.vbgen' to generate them.");
            }
        }
        /// <summary>
        /// Moves the balance.
        /// </summary>
        /// <param name="rpSource">The rp source.</param>
        /// <param name="rpDestination">The rp destination.</param>
        /// <param name="quantityToBeMoved">The quantity to be moved.</param>
        /// <exception cref="System.Exception"></exception>
        public static void MoveBalance(ReceivePallet rpSource, ReceivePallet rpDestination, long quantityToBeMoved)
        {
            TransactionMgr transaction = TransactionMgr.ThreadTransactionMgr();

            transaction.BeginTransaction();
            try
            {
                //DropProcedureReceiveDocReceivePallet();
                if (rpSource.Balance < quantityToBeMoved)
                {
                    throw new Exception("Quantity to be moved must be less than or equal to the balance!");
                }

                if (rpDestination.IsColumnNull("Balance"))
                {
                    rpDestination.Balance = 0;
                }

                rpDestination.Balance          += quantityToBeMoved;
                rpDestination.BoxSize           = 0;
                rpDestination.IsOriginalReceive = rpSource.IsOriginalReceive;
                rpDestination.Save();

                rpSource.BoxSize  = 0;
                rpSource.Balance -= quantityToBeMoved;

                rpSource.Save();
                //CreateProcedureReceiveDocReceivePallet();
                transaction.CommitTransaction();
            }
            catch
            {
                transaction.RollbackTransaction();
                CreateProcedureReceiveDocReceivePallet();
            }
        }
        private void btnChangeTo_Click(object sender, EventArgs e)
        {
            // Do validation
            if (dxErrorCorrectionValidator.Validate() && IsItemDetailValid())
            {
                if (
                    XtraMessageBox.Show("Are you sure you want to commit this change? You will not be able to undo this.",
                                        "Confirmation", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }

                var      unitIdTo         = Convert.ToInt32(lkUnitTo.EditValue);
                var      manufacturerIdTo = Convert.ToInt32(lkManufacturerTo.EditValue);
                var      conversionFactor = Convert.ToDecimal(txtFactor.EditValue);
                var      changeExpiryDate = ckExpiryDate.Checked;
                var      changeBatchNo    = ckBatchNo.Checked;
                var      batchNo          = txtBatchNo.Text;
                var      expiryDate       = (DateTime?)dtExpiryDate.EditValue;
                DateTime dtCurrent;

                using (var dtDate = ConvertDate.GetCurrentEthiopianDateText())
                {
                    dtCurrent = ConvertDate.DateConverter(dtDate.Text);
                }
                TransactionMgr transactionMgr = TransactionMgr.ThreadTransactionMgr();

                int             userId          = CurrentContext.UserId;
                TransferService transferService = new TransferService();

                if (conversionFactor == 0 &&
                    XtraMessageBox.Show(
                        "This change is a factor of Zero make the Quantity Zero,Are you sure you want to commit this change? You will not be able to undo this.",
                        "Confirmation", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }

                try
                {
                    transactionMgr.BeginTransaction();
                    var dataView  = (DataView)gridItemDetailView.DataSource;
                    int IDPRinted = transferService.CreateTransactionForErrorCorrection(dataView, ItemIDTo, unitIdTo,
                                                                                        manufacturerIdTo,
                                                                                        conversionFactor,
                                                                                        "Error Correction",
                                                                                        dtCurrent, userId,
                                                                                        changeExpiryDate, expiryDate,
                                                                                        changeBatchNo, batchNo);

                    transactionMgr.CommitTransaction();

                    var xtraReport = ReturnErrorCorrectionReport(unitIdTo, manufacturerIdTo, dataView, conversionFactor,
                                                                 IDPRinted, changeExpiryDate, expiryDate, changeBatchNo,
                                                                 batchNo);
                    xtraReport.PrintDialog();

                    XtraMessageBox.Show("Your changes have been applied, thanks.", "Confirmation");
                    // refresh
                    btnDisplay_Click(null, null);
                    lkWarehouse_EditValueChanged(null, null);
                    layoutWarehouse.ContentVisible = false;
                    lkWarehouse.Visible            = false;
                }
                catch (Exception exp)
                {
                    XtraMessageBox.Show("There was an error applying your changes", "Error");
                    transactionMgr.RollbackTransaction();
                    XtraMessageBox.Show(exp.Message.ToString());
                }
                finally
                {
                    TransactionMgr.ThreadTransactionMgrReset();
                }
            }
            else
            {
                XtraMessageBox.Show("Please correct the errors marked in red", "Error");
            }
        }
示例#7
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            DataRow dataRow = gridReceiveView.GetFocusedDataRow();

            if (dataRow != null)
            {
                if (Convert.ToInt32(dataRow["ReceiptConfirmationStatusID"]) == ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED)
                {
                    ReceiptID = Convert.ToInt32(dataRow["ReceiptID"]);
                    PrintDialog printDialog = new PrintDialog();
                    printDialog.PrinterSettings.Copies = BLL.Settings.GRNFCopies;

                    DialogResult dialogResult = printDialog.ShowDialog();

                    if (dialogResult != DialogResult.OK)
                    {
                        MessageBox.Show("Printing Canceled by user", "Cancel Printint...", MessageBoxButtons.OK,
                                        MessageBoxIcon.Asterisk);
                        return;
                    }

                    TransactionMgr transaction = TransactionMgr.ThreadTransactionMgr();
                    XtraReport     printout;
                    try
                    {
                        transaction.BeginTransaction();
                        printout = WorkflowReportFactory.CreateGRNFPrintout(ReceiptID, null, false, FiscalYear.Current);
                        var receipt = new BLL.Receipt(ReceiptID);

                        var recDoc = new ReceiveDoc();
                        recDoc.LoadByReceiptID(ReceiptID);


                        if (receipt.ReceiptInvoice.PO.PurchaseType == BLL.POType.STORE_TO_STORE_TRANSFER || !BLL.Settings.HandleGRV)
                        {
                            recDoc.ConfirmGRVPrinted(CurrentContext.UserId);
                            BLL.Receipt receiptStatus = new BLL.Receipt();
                            receiptStatus.LoadByPrimaryKey(ReceiptID);
                            receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRV_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "Transfer Confirmed");
                        }
                        else
                        {
                            recDoc.ConfirmGRNFPrinted(CurrentContext.UserId);

                            BLL.Receipt receiptStatus = new BLL.Receipt();
                            receiptStatus.LoadByPrimaryKey(ReceiptID);
                            receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRNF_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "GRNF Printed");
                        }
                        transaction.CommitTransaction();
                    }
                    catch (Exception exception)
                    {
                        transaction.RollbackTransaction();

                        XtraMessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw;
                    }


                    for (int i = 0; i < printDialog.PrinterSettings.Copies; i++)
                    {
                        printout.Print(printDialog.PrinterSettings.PrinterName);
                    }

                    ReceiptConfirmation_Load(null, null);
                }
                else
                {
                    XtraMessageBox.Show("The selected receipt has to be confirmed before GRNF is printed!", "ERROR", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }
            }
        }
        public void Transactions()
        {
            TransactionMgr tx = TransactionMgr.ThreadTransactionMgr();

            try
            {
                Employees emps = new Employees();
                emps.AddNew();
                emps.FirstName = "Jimmy";
                emps.LastName  = "Lunch Box";

                Products prds = new Products();
                prds.AddNew();
                prds.ProductName  = "dOOdads";
                prds.Discontinued = false;

                tx.BeginTransaction();
                emps.Save();
                prds.Save();
                tx.CommitTransaction();
            }
            catch (Exception)
            {
                tx.RollbackTransaction();
                TransactionMgr.ThreadTransactionMgrReset();
            }

            //-----------------------------------------------------------
            // Moral:
            //-----------------------------------------------------------
            // Modeled after COM+ transactions, but still using ADO.NET
            // connection based transactions you have the best of both
            // worlds.
            //
            // 1) Your transactions paths do not have to be pre-planned.
            //    At any time you can begin a transaction
            //
            // 2) You can nest BeginTransaction/CommitTransaction any number of times as
            //    long as they are sandwiched appropriately
            //
            //    BeginTransaction
            //        BeginTransaction
            //            emps.Save
            //        CommitTransaction
            //    CommitTransaction
            //
            //    Only the final CommitTransaction will commit the transaction
            //
            // 3) Once RollbackTransaction is called the transaction is doomed,
            //    nothing can be committed even it is attempted.
            //
            // 4) Transactions are stored in the Thread Local Storage or
            //    TLS. This way the API isn't intrusive, ie, forcing you
            //    to pass a SqlConnection around everywhere.  There is one
            //    thing to remember, once you call RollbackTransaction you will
            //    be unable to commit anything on that thread until you
            //    call ThreadTransactionMgrReset().
            //
            //    In an ASP.NET application each page is handled by a thread
            //    that is pulled from a thread pool. Thus, you need to clear
            //    out the TLS (thread local storage) before your page begins
            //    execution. The best way to do this is to create a base page
            //    that inhertis from System.Web.UI.Page and clears the state
            //    like this
            //
            //    public class MyPage : System.Web.UI.Page
            //	  {
            //        private void Page_Init(System.Object sender, System.EventArgs e)
            //		  {
            //           TransactionMgr.ThreadTransactionMgrReset();
            //        }
            //    }
            //
            //    And then make sure all of your ASPX pages inherit from MyPage.
            //
            //-----------------------------------------------------------
        }