コード例 #1
0
 private void btnReprintGRV_Click(object sender, EventArgs e)
 {
     MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
     try
     {
         transaction.BeginTransaction();
         DataRow dr = gridReceiveView.GetFocusedDataRow();
         int?    receiptConfirmationPrintoutID = Convert.ToInt32(dr["ID"]);
         PrintConfirmation(receiptConfirmationPrintoutID);
         transaction.CommitTransaction();
     }
     catch (Exception ex)
     {
         transaction.RollbackTransaction();
         XtraMessageBox.Show(ex.Message);
     }
 }
コード例 #2
0
        private void btnMovingAverage_Click(object sender, EventArgs e)
        {
            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            var dialogResult =
                XtraMessageBox.Show(
                    String.Format("Are you Sure you want to Set the  Price for {0}", txtItemName.Text),
                    "Are you sure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }

            if (dialogResult == DialogResult.Yes)
            {
                try
                {
                    transaction.BeginTransaction();
                    // This is where we set the Price
                    JournalService journalService = new JournalService();
                    journalService.StartRecordingSession();
                    costElement.SavePrice(CurrentContext.UserId, "", journalService, ChangeMode.BeginningBalance);
                    journalService.CommitRecordingSession();
                    journalService.StartRecordingSession();
                    costElement.ConfirmPrice(CurrentContext.UserId, "", journalService, ChangeMode.BeginningBalance);
                    journalService.CommitRecordingSession();
                    ReceiveDoc receiveDoc = new ReceiveDoc();
                    receiveDoc.SavePrice(costElement, CurrentContext.UserId);

                    ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation();
                    receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(receiveDocs, ReceiptConfirmationStatus.Constants.GRV_PRINTED, ReceiptConfirmationStatus.Constants.PRICE_CALCULATED);
                    transaction.CommitTransaction();
                    this.Close();
                }
                catch (Exception exception)
                {
                    transaction.RollbackTransaction();
                    XtraMessageBox.Show("Error : " + exception.Message, "Error...", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    throw exception;
                }
            }
        }
コード例 #3
0
 private void OnConfirmClicked(object sender, EventArgs e)
 {
     if (currentMode == Modes.DeliveryNotePrinting)
     {
         MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
         try
         {
             transaction.BeginTransaction();
             SetFinalCost();
             PrintConfirmation(null);
             transaction.CommitTransaction();
         }
         catch (Exception ex)
         {
             transaction.RollbackTransaction();
             XtraMessageBox.Show(ex.Message);
         }
     }
 }
コード例 #4
0
        private void btnReturnToApprovalStep_Click(object sender, EventArgs e)
        {
            //int ordId = Convert.ToInt32(gridApprovedOrdersView.GetFocusedDataRow()["ID"].ToString());
            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            try
            {
                transaction.BeginTransaction();
                Order ord = new Order();
                ord.LoadByPrimaryKey(_orderID);
                if (ord.RowCount > 0 && ord.OrderStatusID == OrderStatus.Constant.ORDER_APPROVED)
                {
                    ord.OrderStatusID = OrderStatus.Constant.ORDER_FILLED;
                    ord.Save();
                    BindApprovedOrders();
                }
                else if (ord.RowCount > 0 && ord.OrderStatusID == OrderStatus.Constant.PICK_LIST_GENERATED)
                {
                    ord.ReleaseReservation();
                    ord.OrderStatusID = OrderStatus.Constant.ORDER_FILLED;
                    ord.Save();
                    BindApprovedOrders();
                }
                transaction.CommitTransaction();
            }
            catch (Exception exp)
            {
                transaction.RollbackTransaction();
                throw exp;
            }
            gridPickListDetail.DataSource = null;
            //HCMISLoader.MarkAsDirtyUsingOrderID(_orderID, NewMainWindow.UserId, true);
            if (BLL.Settings.IsCenter)
            {
                XtraMessageBox.Show("The Issue Order List has been returned to approval stage", "Confirmation",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                XtraMessageBox.Show("The Pick list has been returned to approval stage", "Confirmation",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #5
0
        private void btnReturnToApprovalStep_Click(object sender, EventArgs e)
        {
            //int ordId = Convert.ToInt32(gridApprovedOrdersView.GetFocusedDataRow()["ID"].ToString());
            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            try
            {
                transaction.BeginTransaction();
                Order ord = new Order();
                ord.LoadByPrimaryKey(_orderID);
                if (ord.RowCount > 0 && ord.OrderStatusID == OrderStatus.Constant.ORDER_APPROVED)
                {
                    ord.ChangeStatus(OrderStatus.Constant.ORDER_FILLED, CurrentContext.UserId);;
                    BindApprovedOrders();
                }

                transaction.CommitTransaction();

                this.LogActivity("Return-Pick-List-To-Approval", ord.ID);
            }
            catch (Exception exp)
            {
                transaction.RollbackTransaction();
                throw exp;
            }
            gridPickListDetail.DataSource = null;

            if (BLL.Settings.IsCenter)
            {
                XtraMessageBox.Show("The Issue Order List has been returned to approval stage", "Confirmation",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                XtraMessageBox.Show("The Pick list has been returned to approval stage", "Confirmation",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #6
0
        private void btnRowSave_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            DataRow dataRow = gridLocationRelatedInventoryView.GetFocusedDataRow();

            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            try
            {
                transaction.BeginTransaction();
                if (this.HasPermission("Edit-Commited"))
                {
                    if (dataRow.RowState == DataRowState.Unchanged &&
                        XtraMessageBox.Show("No Record Was Changeed! , Du you still want to proceed? ", "Confirmation",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
                    {
                        return;
                    }

                    InventoryService.SaveInventoryRow(dataRow);

                    transaction.CommitTransaction();
                    XtraMessageBox.Show("Draft successfully saved!", "Success",
                                        System.Windows.Forms.MessageBoxButtons.OK,
                                        System.Windows.Forms.MessageBoxIcon.Information);
                    btnLoadInventory_Click(null, null);
                }
                else
                {
                    throw new Exception("You have no permission, please contact Administrator!");
                }
            }
            catch (Exception exception)
            {
                transaction.RollbackTransaction();
                XtraMessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #7
0
        private void SavePickListItems(object sender, EventArgs e)
        {
            var ord = new Order();
            var rus = new Institution();

            ord.LoadByPrimaryKey(_orderID);
            rus.LoadByPrimaryKey(ord.RequestedBy);

            if (_dvPickListMakeup == null || ValidatePickList())
            {
                return;
            }

            // First of all .. print the pick list
            var pls = new PickList();

            PrintPickList(ord, rus);

            MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
            try
            {
                mgr.BeginTransaction();
                pls.SavePickList(_orderID, _dvPickListMakeup, CurrentContext.UserId);
                mgr.CommitTransaction();

                BindApprovedOrders();
                this.LogActivity("Print-Pick-List", ord.ID);
                XtraMessageBox.Show("Your pick list has been saved! please continue to the next step or prepare another Picklist here.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception exp)
            {
                mgr.RollbackTransaction();
                ViewHelper.ShowErrorMessage("System couldn't save the Pick List, Please contact administrator for additional help", exp);
                ErrorHandler.Handle(exp);
            }
        }
コード例 #8
0
        private void btnSaveAndForward_Click(object sender, EventArgs e)
        {
            if (ValidateForm() && XtraMessageBox.Show(String.Format("Are you sure,you want to Transfer Items To {0}", lkForHub.Text), "Are you Sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                DataView dv = orderGrid.DataSource as DataView;
                if (dxValidation1stTab.Validate())
                {
                    if (dv != null && Convert.ToInt32(lkForHub.EditValue) != -1 && dv.Count != 0)
                    {
                        MyGeneration.dOOdads.TransactionMgr transactionMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

                        try
                        {
                            transactionMgr.BeginTransaction();
                            SaveOrder();
                            ResetOrder();
                            BindMainOrderGrid();
                            transactionMgr.CommitTransaction();
                        }
                        catch (Exception exp)
                        {
                            transactionMgr.RollbackTransaction();
                            XtraMessageBox.Show(exp.Message.ToString());
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("Please select item");
                    }
                }
                else
                {
                    XtraMessageBox.Show("Please change invalid value ");
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Handles the Click event of the btnConfirmIssue control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        /// <exception cref="System.Exception"></exception>
        private void btnConfirmIssue_Click(object sender, EventArgs e)
        {
            // This is where the Issue is actually recorded and the stv is printed.
            // Do all kinds of validations.
            XtraReport STVReport = null; XtraReport DeliveryNoteReport = null;

            btnConfirmIssue1.Enabled = false;
            if (!IssueValid())
            {
                XtraMessageBox.Show("Please Correct the Items Marked in Red before Proceeding with Issue", "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement);
                return;
            }

            if (XtraMessageBox.Show("Are You Sure, You want to save this Transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                DateTimePickerEx dtDate = ConvertDate.GetCurrentEthiopianDateText();

                DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text);
                // The User is now sure that the STV has to be printed and that
                // the order is also good to save.
                // This is the section that does the saving.

                BLL.Order order = new Order();
                order.LoadByPrimaryKey(_orderID);

                // what are the pick lists, do we have devliery notes too?
                DataView  dv         = _dvOutstandingPickList;
                DataTable dvUnpriced = new DataTable();
                DataTable dvPriced   = dv.ToTable();

                if (BLL.Settings.HandleGRV)
                {
                    if (BLL.Settings.IsCenter)
                    {
                        dv.RowFilter = "(Cost is null or Cost=0)";
                    }
                    else
                    {
                        dv.RowFilter = "DeliveryNote = true and (Cost is null or Cost=0)";
                    }
                    dvUnpriced = dv.ToTable();

                    dv.RowFilter = "Cost is not null and Cost <> 0";
                    dvPriced     = dv.ToTable();
                }
                else
                {
                    dvPriced = dv.ToTable();
                }

                string stvPrinterName      = "";
                string deliveryNotePrinter = "";

                if (!ConfirmPrinterSettings(dvPriced, dvUnpriced, out stvPrinterName, out deliveryNotePrinter))
                {
                    return;
                }
                bool saveSuccessful = false;

                MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                try
                {
                    if (dvPriced.Rows.Count == 0 && dvUnpriced.Rows.Count == 0)
                    {
                        throw new Exception("The Items doesn’t meet the requirement: please check the price status for non-delivery notes!");
                    }

                    mgr.BeginTransaction();

                    if (dvPriced.Rows.Count > 0)
                    {
                        STVReport = SaveAndPrintSTV(dvPriced.DefaultView, false, stvPrinterName, dtDate, dtCurrent);
                    }


                    if (dvUnpriced.Rows.Count > 0)
                    {
                        DeliveryNoteReport = SaveAndPrintSTV(dvUnpriced.DefaultView, true, deliveryNotePrinter, dtDate,
                                                             dtCurrent);
                    }
                    var ordr = new Order();
                    ordr.LoadByPrimaryKey(_orderID);

                    if (!ordr.IsColumnNull("OrderTypeID") &&

                        (ordr.OrderTypeID == BLL.OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER || ordr.OrderTypeID == BLL.OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER))
                    {
                        var      transfer         = new Transfer();
                        DateTime convertedEthDate = ConvertDate.DateConverter(dtDate.Text);
                        transfer.CommitAccountToAccountTransfer(ordr.ID, CurrentContext.UserId, convertedEthDate);
                    }

                    mgr.CommitTransaction();

                    saveSuccessful = true;
                }
                catch (Exception exp)
                {
                    mgr.RollbackTransaction();
                    //Removed the reset logic
                    //MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgrReset();
                    XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ErrorHandler.Handle(exp);
                    saveSuccessful = false;
                }

                if (saveSuccessful)
                {
                    if (STVReport != null)
                    {
                        if (InstitutionIType.IsVaccine(GeneralInfo.Current))
                        {
                            for (int i = 0; i < BLL.Settings.STVCopies; i++)
                            {
                                STVReport.Print(stvPrinterName);
                            }
                        }
                        else
                        {
                            STVReport.Print(stvPrinterName);
                        }
                    }

                    if (DeliveryNoteReport != null)
                    {
                        DeliveryNoteReport.Print(deliveryNotePrinter);
                    }

                    XtraMessageBox.Show("Transaction Successfully Saved!", "Success", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                }

                btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement);
                BindOutstandingPicklists();
                gridOutstandingPicklistDetail.DataSource = null;
                PalletLocation.GarbageCollection();

                if (BLL.Settings.AllowOnlineOrders)
                {
                    Helpers.RRFServiceIntegration.SubmitOnlineIssue(_orderID);
                }
            }
        }
コード例 #10
0
        private void btnConfirmIssue_Click(object sender, EventArgs e)
        {
            var Instance = new SoftwareSettings();

            Instance.GetValue("IsCenter");
            dxValidationProvider1.Validate();
            BLL.Issue stv = new BLL.Issue();
            stv.LoadByPrimaryKey(_activeSTVID);
            // bool isValid = dxValidationProvider1.Validate();
            var activity = new Activity();

            activity.LoadByPrimaryKey(stv.StoreID);

            if (activity.IsHealthProgram()) // if (!isValid && Mode.IsFreeStore(stv.StoreID))
            {
                dxValidationProvider1.RemoveControlError(txtPreprintedInvoiceNo);
            }

            if (Convert.ToBoolean(Instance.Value)) // When IsCenter is true. txtPreprintedInvoiceNo should be disabled as a requirment
            {
                dxValidationProvider1.RemoveControlError(txtPreprintedInvoiceNo);
            }

            if (Convert.ToBoolean(Instance.Value) && !activity.IsHealthProgram())
            {
                dxValidationProvider1.RemoveControlError(txtPreprintedInvoiceNo);
            }
            if (!Convert.ToBoolean(Instance.Value) && !activity.IsHealthProgram())  //   if (!isValid && !Mode.IsFreeStore(stv.StoreID))
            {
                if (!dxValidationProvider1.Validate())
                {
                    return;
                }
                //XtraMessageBox.Show("Please input the required fields.", "Required Fields Missing", MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
                //return;
            }
            if (XtraMessageBox.Show("Are you sure you want to confirm this dispatch?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                try
                {
                    mgr.BeginTransaction();
                    //Mark the dispatch as confirmed. (Store the differences in the dispatched values somewhere)
                    int?preprintedID;
                    if (txtPreprintedInvoiceNo.Text == "")
                    {
                        preprintedID = null;
                    }
                    else
                    {
                        preprintedID = int.Parse(txtPreprintedInvoiceNo.Text);
                    }

                    if (!stv.MarkAsDispatched(CurrentContext.UserId, preprintedID))
                    {
                        XtraMessageBox.Show("Void request has been sent for this STV, you can't dispatch it!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        throw new Exception("Void request sent on this STV number");
                    }
                    if (_discrepancyIssueDoc.Count > 0)
                    {
                        //Save the discrepancies.
                        BLL.IssueDoc.RecordDiscrepancy(_discrepancyIssueDoc);
                    }
                    this.LogActivity("Confirm-Dispatch", _activeSTVID);
                    mgr.CommitTransaction();
                    XtraMessageBox.Show("STV marked as dispatched!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception exp)
                {
                    mgr.RollbackTransaction();
                    XtraMessageBox.Show("System couldn't save the dispatch, Please contact administrator", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ErrorHandler.Handle(exp);
                }
                BindUnconfirmedIssues();
                gridUndispatchedIssueDetails.DataSource = null;
            }
        }
コード例 #11
0
        private void SavePickListItems(object sender, EventArgs e)
        {
            BLL.Order       ord = new BLL.Order();
            BLL.Institution rus = new Institution();
            ord.LoadByPrimaryKey(_orderID);


            // if the pick list has already been printed ... go ahead and pass it to the next level
            if (ord.OrderStatusID == OrderStatus.Constant.PICK_LIST_GENERATED)
            {
                ord.OrderStatusID = OrderStatus.Constant.PICK_LIST_CONFIRMED;
                ord.Save();
                BindApprovedOrders();
                gridPickListDetail.DataSource = null;
                XtraMessageBox.Show("The Pick List has been Confirmed", "Confirmation", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                return;
            }

            if (_dvPickListMakeup != null)
            {
                MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                try
                {
                    mgr.BeginTransaction();
                    // First of all .. print the pick list

                    rus.LoadByPrimaryKey(ord.RequestedBy);

                    var pl = HCMIS.Desktop.Reports.WorkflowReportFactory.CreatePicklistReport(ord, rus,
                                                                                              _dvPickListMakeup);
                    pl.PrintDialog();
                    var pls = new PickList();

                    pls.SavePickList(_orderID, _dvPickListMakeup, CurrentContext.UserId);

                    // Refresh the current window
                    BindApprovedOrders();
                    // clear the working grid
                    gridPickListDetail.DataSource = null;
                    mgr.CommitTransaction();
                    XtraMessageBox.Show("Your pick list has been saved! please continue to the next step or prepare another Picklist here.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception exp)
                {
                    mgr.RollbackTransaction();
                    BLL.User user = new User();
                    //user.LoadByPrimaryKey(NewMainWindow.UserId);
                    user = CurrentContext.LoggedInUser;
                    if (user.UserType == UserType.Constants.ADMIN || user.UserType == UserType.Constants.SUPER_ADMINISTRATOR)
                    {
                        XtraMessageBox.Show(exp.Message);
                    }
                    else
                    {
                        XtraMessageBox.Show("System couldn't save the Pick List, Please contact administrator for additional help", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    ErrorHandler.Handle(exp);
                }
            }
        }
コード例 #12
0
        public static void DeleteIssueDoc(int issueID)
        {
            MyGeneration.dOOdads.TransactionMgr tranMgr =
                MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            try
            {
                tranMgr.BeginTransaction();


                var pld  = new PickListDetail();
                var rdoc = new ReceiveDoc();
                var rp   = new ReceivePallet();
                var idoc = new IssueDoc();

                idoc.LoadByPrimaryKey(issueID);
                pld.LoadByPrimaryKey(idoc.PLDetailID);
                rdoc.LoadByPrimaryKey(idoc.RecievDocID);

                rp.LoadByPrimaryKey(pld.ReceivePalletID);
                var pl = new PalletLocation();
                pl.loadByPalletID(rp.PalletID);

                if (pl.RowCount == 0)
                {
                    pl.LoadByPrimaryKey(pld.PalletLocationID);
                    if (pl.IsColumnNull("PalletID"))
                    {
                        pl.PalletID = rp.PalletID;
                        pl.Save();
                    }
                }


                if (rp.RowCount == 0)
                {
                    XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error");
                    return;
                }
                if (rp.RowCount > 0)
                {
                    // in error cases this could lead to a number greater than the received quantity
                    // instead of being an error, it should just delete the respective issue and
                    // adjust the remaining quantity to the received quantity.
                    if (rdoc.QuantityLeft + idoc.Quantity > rdoc.Quantity)
                    {
                        rdoc.QuantityLeft = rp.Balance = rdoc.Quantity;
                    }
                    else
                    {
                        rdoc.QuantityLeft += idoc.Quantity;
                        rp.Balance        += idoc.Quantity;
                    }

                    //Delete from picklistDetail and add to pickListDetailDeleted
                    PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId);
                    pld.MarkAsDeleted();

                    // are we adding it the pick face?
                    // if so add it to the balance of the pick face also
                    pl.loadByPalletID(rp.PalletID);

                    if (pl.RowCount == 0)
                    {
                        var plocation = new PutawayLocation(rdoc.ItemID);

                        // we don't have a location for this yet,
                        // select a new location
                        //PutawayLocataion pl = new PutawayLocataion();
                        if (plocation.ShowDialog() == DialogResult.OK)
                        {
                            pl.LoadByPrimaryKey(plocation.PalletLocationID);
                            if (pl.RowCount > 0)
                            {
                                pl.PalletID = rp.PalletID;
                                pl.Save();
                            }
                        }
                    }

                    if (pl.RowCount > 0)
                    {
                        var pf = new PickFace();
                        pf.LoadByPalletLocation(pl.ID);
                        if (pf.RowCount > 0)
                        {
                            pf.Balance += Convert.ToInt32(idoc.Quantity);
                            pf.Save();
                        }


                        IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId);
                        idoc.MarkAsDeleted();
                        rdoc.Save();
                        rp.Save();
                        idoc.Save();
                        pld.Save();


                        // now refresh the window
                        XtraMessageBox.Show("Issue Deleted!", "Confirmation", MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        tranMgr.CommitTransaction();
                    }
                }
                else
                {
                    XtraMessageBox.Show(
                        "This delete is not successfull because a free pick face location was not selected. please select a free location and try again.",
                        "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    tranMgr.RollbackTransaction();
                }
            }
            catch
            {
                XtraMessageBox.Show("This delete is not successfull", "Warning ...", MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                tranMgr.RollbackTransaction();
            }
        }
コード例 #13
0
        private void startbgWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            MyGeneration.dOOdads.TransactionMgr transactionMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            try
            {
                // Add the inventory details.
                // For each Activity, populate the inventory.
                //ToDO: this grid reading in a non ui thread is dangerous
                //please don't do it this way.
                transactionMgr.BeginTransaction();
                int           physicalStoreID = Convert.ToInt32(gridManageInvetoryView.GetFocusedDataRow()["ID"]);
                PhysicalStore physicalStore   = new PhysicalStore();
                physicalStore.LoadByPrimaryKey(physicalStoreID);


                DateTime startDate = dtStartInventory.Value;
                if (!physicalStore.IsColumnNull("CurrentInventoryPeriodID"))
                {
                    // create the inventory period
                    InventoryPeriod oldPeriod = new InventoryPeriod();
                    oldPeriod.LoadByPrimaryKey(physicalStore.CurrentInventoryPeriodID);
                    oldPeriod.EndDate = dtStartInventory.Value;
                    oldPeriod.Save();
                }
                InventoryPeriod period = new InventoryPeriod();
                period.AddNew();
                period.InventoryStatusID = InventoryPeriod.Constants.BEGIN_INVENTORY;
                period.PhysicalStoreID   = physicalStoreID;
                period.StartDate         = dtStartInventory.Value;
                period.EndDate           = FiscalYear.Current.EndDate;
                period.StartedBy         = CurrentContext.UserId;
                period.FiscalYearID      = FiscalYear.Current.ID;
                if (memoEdit1.EditValue != null)
                {
                    period.Remark = memoEdit1.EditValue.ToString();
                }

                period.Save();
                //ChangePhysicalStoreToCurrentPeriod

                physicalStore = new PhysicalStore();
                physicalStore.LoadByPrimaryKey(physicalStoreID);
                physicalStore.CurrentInventoryPeriodID = period.ID;
                physicalStore.CurrentPeriodStartDate   = period.StartDate;
                physicalStore.Save();

                Activity activity = new Activity();
                activity.LoadAll();
                int activityIndex = 1;
                while (!activity.EOF)
                {
                    // report that this activity is being processed.
                    startbgWorker.ReportProgress(activityIndex++, "Activity: " + activity.FullActivityName);

                    DataTable dtbl  = Balance.GetBalanceByPhysicalStore(physicalStoreID, activity.ID, false);
                    decimal   total = dtbl.Rows.Count;
                    decimal   i     = 0;
                    foreach (DataRow dr in dtbl.Rows)
                    {
                        Inventory inv = new Inventory();
                        inv.AddNew();

                        inv.IsDraft         = true;
                        inv.PhysicalStoreID = physicalStoreID;
                        inv.RecordedBy      = CurrentContext.UserId;
                        inv.RecordedDate    = BLL.DateTimeHelper.ServerDateTime;

                        inv.InventoryPeriodID = period.ID;
                        inv.ItemID            = Convert.ToInt32(dr["ID"]);
                        inv.UnitID            = Convert.ToInt32(dr["UnitID"]);
                        inv.ActivityID        = activity.ID;
                        inv.ManufacturerID    = Convert.ToInt32(dr["ManufacturerID"]);
                        inv.SetColumn("BatchNo", dr["BatchNo"]);
                        inv.SetColumn("ExpiryDate", dr["ExpDate"]);
                        if (!inv.IsColumnNull("ExpiryDate") && inv.ExpiryDate < BLL.DateTimeHelper.ServerDateTime)
                        {
                            inv.SystemExpiredQuantity = Convert.ToDecimal(dr["SoundSOH"]);
                        }
                        else
                        {
                            inv.SystemSoundQuantity = Convert.ToDecimal(dr["SoundSOH"]);
                        }

                        inv.SystemDamagedQuantity = Convert.ToDecimal(dr["DamagedSOH"]);
                        inv.SetColumn("Cost", dr["Cost"]);
                        inv.Margin = dr["Margin"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["Margin"]);
                        inv.SetColumn("PalletLocationID", dr["PalletLocationID"]);
                        inv.Save();


                        startbgWorker.ReportProgress(Convert.ToInt32((i / total) * 100), "Detail");
                        //inventory
                        i++;
                    }


                    activity.MoveNext();
                }
                transactionMgr.CommitTransaction();
                XtraMessageBox.Show("The new Inventory Period has been defined.");
            }
            catch (Exception exception)
            {
                transactionMgr.RollbackTransaction();
                XtraMessageBox.Show(exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #14
0
        private void btnCommit_Click(object sender, EventArgs e)
        {
            if (ValidateQuarantine())
            {
                MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                transaction.BeginTransaction();
                if (DialogResult.Yes == XtraMessageBox.Show("Are you sure you want to commit the Loss and Adjustment on this screen?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    // do the actual commit here.
                    int            printNubmer = InternalTransfer.GetNewPrintNumber() + 1;
                    PalletLocation pl          = new PalletLocation();
                    Pallet         p           = new Pallet();
                    ReceiveDoc     rdoc        = new ReceiveDoc();
                    ReceivePallet  rp          = new ReceivePallet();
                    for (int i = 0; i < gridView1.RowCount; i++)
                    {
                        DataRow dr       = gridView1.GetDataRow(i);
                        Double  writeoff = 0;
                        Double  reLocate = 0;
                        try
                        {
                            if (dr["WriteOff"] != DBNull.Value)
                            {
                                writeoff = Double.Parse(dr["WriteOff"].ToString());
                            }
                            if (dr["ReLocate"] != DBNull.Value)
                            {
                                reLocate = Double.Parse(dr["ReLocate"].ToString());
                            }
                        }
                        catch (Exception exc)
                        {
                        }

                        if (dr["WriteOff"] != DBNull.Value & writeoff > 0)
                        {
                            if (Double.Parse(dr["WriteOff"].ToString()) > Double.Parse(dr["Balance"].ToString()))
                            {
                                XtraMessageBox.Show("Couldn't commit to the numbers you specified. Please specify number less than the balance.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                            int writeoffAmout = Convert.ToInt32(dr["WriteOff"]);
                            int qtyPerPack    = Convert.ToInt32(dr["QtyPerPack"]);
                            writeoffAmout *= qtyPerPack;
                            rp.LoadByPrimaryKey(Convert.ToInt32(dr["ReceivePalletID"]));
                            rdoc.LoadByPrimaryKey(rp.ReceiveID);
                            string x = dr["NewPalletLocation"].ToString();
                            rp.Balance -= writeoffAmout;
                            try
                            {
                                //  rp.ReceivedQuantity -= writeoffAmout;
                            }
                            catch { }
                            rdoc.QuantityLeft -= writeoffAmout;

                            ReceivePallet nrp = new ReceivePallet();
                            nrp.AddNew();
                            nrp.ReceiveID = rp.ReceiveID;
                            nrp.PalletID  = pl.GetpalletidbyPalletLocationOrgetnew(int.Parse(dr["NewPalletLocation"].ToString()));
                            //nrp.ReceivedQuantity = rp.ReceivedQuantity;
                            nrp.Balance       = writeoffAmout;
                            nrp.ReservedStock = 0;
                            //nrp.ReserveOrderID = rp.ReserveOrderID;
                            nrp.BoxSize           = rp.BoxSize;
                            nrp.PalletLocationID  = int.Parse(dr["NewPalletLocation"].ToString());
                            nrp.IsOriginalReceive = rp.IsOriginalReceive;



                            BLL.LossAndAdjustment d = new BLL.LossAndAdjustment();
                            d.AddNew();
                            d.GenerateRefNo();
                            d.ItemID   = Convert.ToInt32(dr["ItemID"]);
                            d.ReasonId = Convert.ToInt32(dr["Reason"]);
                            d.RecID    = rdoc.ID;
                            d.Quantity = writeoffAmout;
                            d.BatchNo  = rdoc.BatchNo;

                            CalendarLib.DateTimePickerEx edate = new CalendarLib.DateTimePickerEx();
                            edate.Value = DateTime.Today;
                            //TODO: fix to an ethiopian date here
                            edate.CustomFormat = "MM/dd/yyyy";

                            d.Date = ConvertDate.DateConverter(edate.Text);

                            d.EurDate = DateTime.Today;
                            d.Cost    = rdoc.IsColumnNull("Cost")? 0: Math.Abs(rdoc.Cost * writeoffAmout);
                            d.StoreId = rdoc.StoreID;
                            d.Losses  = true;
                            //todo:
                            d.ApprovedBy = CurrentContext.UserId.ToString();
                            //d.Remarks

                            InternalTransfer it = new  InternalTransfer();
                            it.AddNew();
                            it.ItemID = d.ItemID;
                            it.FromPalletLocationID = pl.GetPalletLocationIDByPalletID(int.Parse(dr["PalletID"].ToString()));
                            it.ToPalletLocationID   = nrp.PalletLocationID;
                            it.BatchNumber          = d.BatchNo;
                            if (!rdoc.IsColumnNull("ExpDate"))
                            {
                                it.ExpireDate = rdoc.ExpDate;
                            }
                            it.ReceiveDocID   = rdoc.ID;
                            it.ManufacturerID = rdoc.ManufacturerId;
                            it.QtyPerPack     = Convert.ToInt32(dr["QtyPerPack"]);
                            it.Packs          = rdoc.NoOfPack;
                            it.QuantityInBU   = nrp.Balance;


                            LossAndAdjustmentReason r = new LossAndAdjustmentReason();
                            it.Type = r.GetReasonByID(d.ReasonId);


                            // d.Save();
                            rdoc.Save();
                            rp.Save();

                            rdoc.QuantityLeft += writeoffAmout;
                            rdoc.Save();
                            nrp.Save();
                            it.Save();
                            int xs = it.ID;
                        }
                        else if (dr["ReLocate"] != DBNull.Value & reLocate > 0)
                        {
                            if (dr["ReLocate"] != DBNull.Value)
                            {
                                int amount     = Convert.ToInt32(dr["ReLocate"]);
                                int qtyPerPack = Convert.ToInt32(dr["QtyPerPack"]);
                                amount *= qtyPerPack;
                                rp.LoadByPrimaryKey(Convert.ToInt32(dr["ReceivePalletID"]));
                                rdoc.LoadByPrimaryKey(rp.ReceiveID);
                                int palletLocationID = Convert.ToInt32(dr["PalletLocationID"]);

                                int qPalletLocationID =
                                    PalletLocation.GetQuaranteenPalletLocationByPalletLocationID(palletLocationID); //PalletLocation.GetQuaranteenPalletLocation(Convert.ToInt32(dr["ID"]));
                                pl.LoadByPrimaryKey(qPalletLocationID);

                                ReceivePallet rp2    = new ReceivePallet();
                                ReceiveDoc    rd     = new ReceiveDoc();
                                Pallet        pallet = new Pallet();
                                rp.LoadByPrimaryKey(Convert.ToInt32(dr["ReceivePalletID"]));
                                rd.LoadByPrimaryKey(rp.ReceiveID);
                                pallet.AddNew();
                                Item item = new Item();
                                item.LoadByPrimaryKey(rdoc.ItemID);
                                if (item.StorageTypeID.ToString() == StorageType.BulkStore)
                                {
                                    pallet.PalletNo = Pallet.GetLastPanelNumber();
                                }
                                pallet.Save();
                                rp2.AddNew();
                                rp2.PalletID          = pl.GetpalletidbyPalletLocationOrgetnew(int.Parse(dr["NewPalletLocation"].ToString()));//pallet.ID;
                                rp2.ReceiveID         = rp.ReceiveID;
                                rp2.IsOriginalReceive = rp.IsOriginalReceive;
                                // calculate the new balance
                                BLL.ItemManufacturer im = new BLL.ItemManufacturer();
                                //im.LoadDefaultReceiving(rd.ItemID, Convert.ToInt32(dr["ManufacturerID"]));
                                //im.LoadIMbyLevel(rd.ItemID, Convert.ToInt32(dr["ManufacturerID"]), Convert.ToInt32(dr["BoxLevel"]));
                                //int packqty = (amount / im.QuantityInBasicUnit);
                                rd.QuantityLeft -= amount;
                                rp.Balance      -= amount;
                                rd.Save();
                                rp.Save();

                                rd.QuantityLeft += amount;
                                rp2.Balance      = amount;//packqty * im.QuantityInBasicUnit;
                                rd.Save();

                                rp2.BoxSize          = rp.BoxSize;
                                rp2.ReservedStock    = 0;
                                rp2.PalletLocationID = int.Parse(dr["NewPalletLocation"].ToString());
                                rp2.Save();

                                pl.Confirmed = false;
                                pl.Save();

                                // select the new pallet location here.

                                /*   XtraForm xdb = new XtraForm();
                                 * xdb.Controls.Add(panelControl2);
                                 * Item itms= new Item();
                                 * itms.GetItemByPrimaryKey(Convert.ToInt32(dr["ItemID"]));
                                 * lblItemName.Text = itms.FullItemName;
                                 * panelControl2.Visible = true;
                                 * panelControl2.Dock = DockStyle.Fill;
                                 * xdb.Text = "Select Location for relocated Item";
                                 * lkLocation.Properties.DataSource = PalletLocation.GetAllFreeFor(Convert.ToInt32(dr["ItemID"]));
                                 * xdb.ShowDialog();
                                 *
                                 * PalletLocation pl2 = new PalletLocation();
                                 * pl2.LoadByPrimaryKey(Convert.ToInt32(lkLocation.EditValue));
                                 * pl2.PalletID = pallet.ID;
                                 * pl2.Confirmed = false;
                                 * pl2.Save();
                                 */
                                InternalTransfer it = new InternalTransfer();

                                it.AddNew();
                                it.ItemID   = rd.ItemID;
                                it.BoxLevel = 0; // im.PackageLevel;
                                //it.ExpireDate = rd.ExpDate;
                                if (!rd.IsColumnNull("ExpDate"))
                                {
                                    it.ExpireDate = rd.ExpDate;
                                }
                                it.BatchNumber          = rd.BatchNo;
                                it.ManufacturerID       = Convert.ToInt32(dr["ManufacturerID"]);         //im.ManufacturerID;
                                it.FromPalletLocationID = qPalletLocationID;
                                it.ToPalletLocationID   = int.Parse(dr["NewPalletLocation"].ToString()); //pl2.ID;
                                it.QtyPerPack           = 1;
                                //it.Packs = pack qty;
                                it.ReceiveDocID = rp.ReceiveID;
                                it.QuantityInBU = amount; // it.QtyPerPack;
                                it.Type         = "ReLocation";
                                it.IssuedDate   = DateTime.Today;
                                it.Status       = 0;
                                it.PrintNumber  = printNubmer;
                                it.Save();
                            }
                        }
                    }
                    transaction.CommitTransaction();
                    BindQuarantine();
                    XtraMessageBox.Show("Quarantine Write off/Adjustment was commitd.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
コード例 #15
0
        private void ConfirmQuantityAndLocation()
        {
            //TODO: finish updating the changed locations
            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
            transaction.BeginTransaction();
            try
            {
                PalletLocation 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"]);
                    int PalletID  = Convert.ToInt32(drv["PalletID"]);
                    int receiveID = Convert.ToInt32(drv["ReceiveID"]);

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

                            pl.LoadByPrimaryKey(ProposedPalletLocationID);
                            pl.SetColumnNull("PalletID");
                            pl.Save();
                        }
                        else
                        {
                            XtraMessageBox.Show("Some Items/Pallets were not confirmed correctly because the newly selected pallet location was already occupied.", "Some Items were not confirmed.");
                        }
                    }
                    else
                    {
                        pl.LoadByPrimaryKey(PalletLocationID);
                        pl.PalletID  = PalletID;
                        pl.Confirmed = true;
                        pl.Save();
                    }
                }

                BLL.ReceiveDoc recDoc = new ReceiveDoc();
                recDoc.LoadByReferenceNo(reference);
                recDoc.ConfirmQuantityAndLocation(null);

                transaction.CommitTransaction();
                XtraMessageBox.Show("Receipt Confirmed!", "Success", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                BindFormContents();
            }
            catch (Exception exp)
            {
                transaction.RollbackTransaction();
                XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();


            if (gridPriceList.DataSource != null && (gridPriceList.DataSource as DataTable).GetChanges() != null)
            {
                DataTable dtChangedPricelist = (gridPriceList.DataSource as DataTable).GetChanges();
                if (dtChangedPricelist != null)
                {
                    foreach (DataRowView drw in dtChangedPricelist.DefaultView)
                    {
                        var dialogResult =
                            XtraMessageBox.Show(
                                String.Format("Are you Sure you want to Change Price for {0}", drw["ItemName"]),
                                "Are you sure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                        if (dialogResult == DialogResult.Cancel)
                        {
                            return;
                        }

                        if (dialogResult == DialogResult.Yes)
                        {
                            try
                            {
                                transaction.BeginTransaction();
                                // This is where we set the Price
                                JournalService journalService = new JournalService();
                                journalService.StartRecordingSession();
                                CostElement costElement = new CostElement(Convert.ToInt32(drw["ItemID"])
                                                                          , Convert.ToInt32(drw["MovingAverageGroupID"])
                                                                          , Convert.ToInt32(drw["ManufacturerID"])
                                                                          , Convert.ToInt32(drw["UnitID"]));

                                costElement.AverageCost = Math.Round(Convert.ToDouble(drw["UnitCost"]),
                                                                     BLL.Settings.NoOfDigitsAfterTheDecimalPoint,
                                                                     MidpointRounding.AwayFromZero);
                                costElement.Margin = Math.Round(Convert.ToDouble(drw["Margin"]),
                                                                BLL.Settings.NoOfDigitsAfterTheDecimalPoint + 2,
                                                                MidpointRounding.AwayFromZero);
                                if (BLL.Settings.IsCenter)
                                {
                                    costElement.SellingPrice = costElement.AverageCost;
                                }
                                else
                                {
                                    costElement.SellingPrice = Math.Round(Convert.ToDouble(drw["SellingPrice"]),
                                                                          BLL.Settings.NoOfDigitsAfterTheDecimalPoint,
                                                                          MidpointRounding.AwayFromZero);
                                }


                                costElement.SavePrice(CurrentContext.UserId, "", journalService, ChangeMode.PriceOverride);

                                PriceOverridePrintout report = new PriceOverridePrintout();
                                report.xrCostedBy.Text = CurrentContext.LoggedInUserName;
                                report.lblDate.Text    = DateTimeHelper.ServerDateTime.ToString();
                                report.DataSource      = getPriceChangeReport(costElement);

                                journalService.CommitRecordingSession();
                                transaction.CommitTransaction();

                                report.ShowPreviewDialog();
                            }
                            catch (Exception exception)
                            {
                                transaction.RollbackTransaction();
                                XtraMessageBox.Show("Error : " + exception.Message, "Error...", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Error);
                                throw exception;
                            }
                        }
                    }
                    BindDataSet();
                    XtraMessageBox.Show("Change was Successfull", "Success...", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    return;
                }
            }

            XtraMessageBox.Show("No Changes have been made", "No Changes...", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
コード例 #17
0
        private void tpDelete_Click(object sender, EventArgs e)
        {
            DataRow dr = gridViewBinCard.GetFocusedDataRow();

            if (Convert.ToInt32(dr["Precedance"]) != 3)
            {
                XtraMessageBox.Show("You cannot delete this");
                return;
            }
            if (CurrentContext.LoggedInUser.UserType == UserType.Constants.DISTRIBUTION_MANAGER_WITH_DELETE)
            {
                if (
                    XtraMessageBox.Show(
                        "Are you sure you want to delete this transaction? You will not be able to undo this.",
                        "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    MyGeneration.dOOdads.TransactionMgr tranMgr =
                        MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

                    try
                    {
                        tranMgr.BeginTransaction();

                        ReceiveDoc    rdoc = new ReceiveDoc();
                        ReceivePallet rp   = new ReceivePallet();
                        IssueDoc      idoc = new IssueDoc();

                        PickListDetail pld     = new PickListDetail();
                        int            issueID = Convert.ToInt32(dr["ID"]);
                        //pld.LoadByOrderAndItem(Convert.ToInt32(dr["OrderID"]), Convert.ToInt32(dr["ItemID"]),
                        //                       Convert.ToInt32(dr["Quantity"]));
                        idoc.LoadByPrimaryKey(issueID);
                        pld.LoadByPrimaryKey(idoc.PLDetailID);

                        string RefNo = idoc.RefNo;

                        rdoc.LoadByPrimaryKey(idoc.RecievDocID);


                        //if (pld.RowCount == 0)
                        //{
                        //    pld.LoadByOrderAndItem(Convert.ToInt32(dr["OrderID"]), Convert.ToInt32(dr["ItemID"]));
                        //}

                        rp.LoadByPrimaryKey(pld.ReceivePalletID);
                        PalletLocation pl = new PalletLocation();
                        pl.loadByPalletID(rp.PalletID);

                        if (pl.RowCount == 0)
                        {
                            pl.LoadByPrimaryKey(pld.PalletLocationID);
                            if (pl.IsColumnNull("PalletID"))
                            {
                                pl.PalletID = rp.PalletID;
                                pl.Save();
                            }
                            //rp.LoadNonZeroRPByReceiveID(rdoc.ID);
                        }


                        if (rp.RowCount == 0)
                        {
                            XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error");
                            return;
                        }
                        if (rp.RowCount > 0)
                        {
                            rdoc.QuantityLeft += idoc.Quantity;
                            rp.Balance        += idoc.Quantity;
                            pld.QuantityInBU   = 0;


                            // are we adding it the pick face?
                            // if so add it to the balance of the pick face also
                            pl.loadByPalletID(rp.PalletID);

                            if (pl.RowCount == 0)
                            {
                                PutawayLocation plocation = new PutawayLocation(rdoc.ItemID);

                                // we don't have a location for this yet,
                                // select a new location
                                //PutawayLocataion pl = new PutawayLocataion();
                                if (plocation.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                                {
                                    pl.LoadByPrimaryKey(plocation.PalletLocationID);
                                    if (pl.RowCount > 0)
                                    {
                                        pl.PalletID = rp.PalletID;
                                        pl.Save();
                                    }
                                }
                            }

                            if (pl.RowCount > 0)
                            {
                                PickFace pf = new PickFace();
                                pf.LoadByPalletLocation(pl.ID);
                                if (pf.RowCount > 0)
                                {
                                    pf.Balance += Convert.ToInt32(idoc.Quantity);
                                    pf.Save();
                                }


                                IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId);
                                idoc.MarkAsDeleted();
                                rdoc.Save();
                                rp.Save();
                                idoc.Save();


                                // now refresh the window
                                XtraMessageBox.Show("Issue Deleted!", "Confirmation", MessageBoxButtons.OK,
                                                    MessageBoxIcon.Information);
                                tranMgr.CommitTransaction();
                                //TODO: refresh the list
                                // gridViewReferences_FocusedRowChanged(null, null);
                            }
                        }
                        else
                        {
                            XtraMessageBox.Show(
                                "This delete is not successfull because a free pick face location was not selected. please select a free location and try again.",
                                "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            tranMgr.RollbackTransaction();
                        }
                    }
                    catch
                    {
                        XtraMessageBox.Show("This delete is not successfull", "Warning ...", MessageBoxButtons.OK,
                                            MessageBoxIcon.Warning);
                        tranMgr.RollbackTransaction();
                    }
                }
            }
            else
            {
                XtraMessageBox.Show(
                    "You cannot delete this transaction because you don't have previlage. Please contact the administrator if you thing this is an error.",
                    "Delete is not allowed");
            }
        }
コード例 #18
0
        /// <summary>
        /// Change the UnitID of one item to another UnitID.
        /// </summary>
        /// <param name="storeID"></param>
        /// <param name="itemID"></param>
        /// <param name="fromUnitID"></param>
        /// <param name="toUnitID"></param>
        public static void ChangeItemUnit(int storeID, int itemID, int fromUnitID, int toUnitID)
        {
            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
            try
            {
                transaction.BeginTransaction();
                ItemUnit iuFrom = new ItemUnit(), iuTo = new ItemUnit(), iuExecute = new ItemUnit();
                iuFrom.LoadByPrimaryKey(fromUnitID);
                iuTo.LoadByPrimaryKey(toUnitID);

                var receiveTableFilterQuery = HCMIS.Repository.Queries.ItemUnit.SelectChangeItemUnit(storeID, itemID, iuFrom.ID);

                string query;
                // Update Issue Doc
                query =
                    HCMIS.Repository.Queries.ItemUnit.UpdateChangeItemUnitIssueDoc(iuTo.QtyPerUnit, iuFrom.QtyPerUnit, receiveTableFilterQuery);
                iuExecute.LoadFromRawSql(query);

                // Update disposal table
                query =
                    HCMIS.Repository.Queries.ItemUnit.UpdateChangeItemUnitLossAndAdjustment(iuTo.QtyPerUnit, iuFrom.QtyPerUnit, receiveTableFilterQuery);
                iuExecute.LoadFromRawSql(query);

                // Update Order.
                query =
                    HCMIS.Repository.Queries.ItemUnit.UpdateChangeItemUnitOrderDetail(itemID, iuFrom.ID, iuFrom.QtyPerUnit, iuTo.QtyPerUnit);

                iuExecute.LoadFromRawSql(query);

                // Update Pick List Detail
                query =
                    HCMIS.Repository.Queries.ItemUnit.UpdateChangeItemUnitPickListDetail(iuTo.QtyPerUnit, iuFrom.QtyPerUnit, receiveTableFilterQuery);

                iuExecute.LoadFromRawSql(query);

                // change the Weighted Average Log
                try
                {
                    query = HCMIS.Repository.Queries.ItemUnit.UpdateChangeItemUnitMovingAverageHistory(storeID, iuTo.ID, iuFrom.ID);

                    iuExecute.LoadFromRawSql(query);
                }

                catch
                {
                }

                BLL.ReceiveDoc rd = new ReceiveDoc();
                rd.LoadByItemIDUnitIDStoreID(itemID, iuFrom.ID, storeID);
                rd.ChangeUnitID(iuTo.ID);

                //Change the YearEnd
                //If there is already an entry with the other UnitID, we need to merge the two.

                BLL.YearEnd yEndFrom = new YearEnd();
                yEndFrom.Where.UnitID.Value  = iuFrom.ID;
                yEndFrom.Where.ItemID.Value  = itemID;
                yEndFrom.Where.StoreID.Value = storeID;
                yEndFrom.Query.Load();

                if (yEndFrom.RowCount > 0)
                {
                    //There is a year end entry.
                    //If there is one by the new UnitID, we merge them.  If there is no entry by the new UnitID, we just change the values.
                    BLL.YearEnd yEndTo = new YearEnd();
                    yEndTo.Where.UnitID.Value  = iuTo.ID;
                    yEndTo.Where.ItemID.Value  = itemID;
                    yEndTo.Where.StoreID.Value = storeID;
                    yEndTo.Query.Load();
                    if (yEndTo.RowCount > 0)
                    {
                        //We need to merge.
                        if (!yEndTo.IsColumnNull("EndingPrice"))
                        {
                            yEndTo.EndingPrice += yEndFrom.EndingPrice;
                        }
                        else
                        {
                            yEndTo.EndingPrice = yEndFrom.EndingPrice;
                        }
                        if (!yEndTo.IsColumnNull("EBalance"))
                        {
                            yEndTo.EBalance += yEndFrom.EBalance;
                        }
                        else
                        {
                            yEndTo.EBalance = yEndFrom.EBalance;
                        }
                        if (!yEndTo.IsColumnNull("PhysicalInventory"))
                        {
                            yEndTo.PhysicalInventory += yEndFrom.PhysicalInventory;
                        }
                        else
                        {
                            yEndTo.PhysicalInventory = yEndFrom.PhysicalInventory;
                        }
                        if (!yEndTo.IsColumnNull("PhysicalInventoryPrice"))
                        {
                            yEndTo.PhysicalInventoryPrice += yEndFrom.PhysicalInventoryPrice;
                        }
                        else
                        {
                            yEndTo.PhysicalInventoryPrice = yEndFrom.PhysicalInventoryPrice;
                        }

                        yEndTo.Save();
                        yEndFrom.MarkAsDeleted();
                        yEndFrom.Save();
                    }
                    else
                    {
                        yEndFrom.UnitID = iuTo.ID;
                        yEndFrom.Save();
                    }
                }
                transaction.CommitTransaction();
            }
            catch (Exception ex)
            {
                transaction.RollbackTransaction();
                throw ex;
            }
        }
コード例 #19
0
        private void btnSetNewPrice_Click(object sender, EventArgs e)
        {
            bool       validated = false;
            ReceiveDoc rd        = new ReceiveDoc();

            validated = dxValidationProviderPrice.Validate();


            if (!validated)
            {
                XtraMessageBox.Show("Please fill in all required fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!isConfirmation)
            {
                if (XtraMessageBox.Show("Are u sure, you want to save the new price change?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    MyGeneration.dOOdads.TransactionMgr transactionMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                    transactionMgr.BeginTransaction();
                    try
                    {
                        rs.NewUnitCost           = Convert.ToDouble(txtAverageCost.EditValue);
                        rs.Margin                = Convert.ToDouble(txtMargin.EditValue);
                        rs.NewSellingPrice       = Convert.ToDouble(txtSellingPrice.EditValue);
                        rs.NewPrice              = rs.NewSellingPrice;
                        rs.Remark                = txtRemark.Text;
                        costElement.AverageCost  = rs.NewUnitCost;
                        costElement.Margin       = rs.Margin;
                        costElement.SellingPrice = rs.NewSellingPrice;
                        Item itm = new Item();
                        itm.LoadByPrimaryKey(rs.ItemID);
                        itm.IsFree = false;

                        itm.Save();

                        rd.SavePrice(rs, CurrentContext.UserId);
                        try
                        {
                            IJournalService journal = new JournalService();
                            journal.StartRecordingSession();
                            costElement.SavePrice(CurrentContext.UserId, "", journal, ChangeMode.PriceOverride);
                            journal.CommitRecordingSession();
                            journal.StartRecordingSession();
                            costElement.ConfirmPrice(CurrentContext.UserId, "", journal, ChangeMode.PriceOverride);
                            journal.CommitRecordingSession();
                        }
                        catch (Exception exception)
                        {
                            // since Cost tier is not Full Started
                        }
                        transactionMgr.CommitTransaction();
                    }
                    catch (Exception ex)
                    {
                        transactionMgr.RollbackTransaction();
                        XtraMessageBox.Show("Price setting failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw ex;
                    }
                    XtraMessageBox.Show("Price setting successful", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                if (XtraMessageBox.Show("Are you sure you want to approve the new price change.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    rd.ConfirmMovingAverage(rs, CurrentContext.UserId);
                    XtraMessageBox.Show("Price setting successful", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            ResetForm();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            DataView dtChangedPricelist = gridViewPriceList.DataSource as DataView;

            if (dtChangedPricelist != null)
            {
                dtChangedPricelist.RowFilter = "IsConfirmed = 1";

                foreach (DataRowView drw in dtChangedPricelist)
                {
                    var dialogResult =
                        XtraMessageBox.Show(
                            String.Format("Are you Sure you want to Change Price for {0}", drw["ItemName"]),
                            "Are you sure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (dialogResult == DialogResult.Cancel)
                    {
                        return;
                    }

                    if (dialogResult == DialogResult.Yes)
                    {
                        try
                        {
                            transaction.BeginTransaction();
                            // This is where we set the Price
                            JournalService journalService = new JournalService();
                            journalService.StartRecordingSession();
                            CostElement costElement = new CostElement(Convert.ToInt32(drw["ItemID"])
                                                                      , Convert.ToInt32(drw["MovingAverageGroupID"])
                                                                      , Convert.ToInt32(drw["ManufacturerID"])
                                                                      , Convert.ToInt32(drw["UnitID"]));

                            costElement.AverageCost = Math.Round(Convert.ToDouble(drw["UnitCost"]),
                                                                 BLL.Settings.NoOfDigitsAfterTheDecimalPoint,
                                                                 MidpointRounding.AwayFromZero);
                            costElement.Margin = Math.Round(Convert.ToDouble(drw["Margin"]),
                                                            BLL.Settings.NoOfDigitsAfterTheDecimalPoint + 2,
                                                            MidpointRounding.AwayFromZero);
                            costElement.SellingPrice = Math.Round(Convert.ToDouble(drw["SellingPrice"]),
                                                                  BLL.Settings.NoOfDigitsAfterTheDecimalPoint,
                                                                  MidpointRounding.AwayFromZero);


                            costElement.ConfirmPrice(CurrentContext.UserId, "", journalService, ChangeMode.PriceOverride);
                            ReceiveDoc receiveDoc = new ReceiveDoc();
                            receiveDoc.SavePrice(costElement, CurrentContext.UserId);
                            journalService.CommitRecordingSession();
                            transaction.CommitTransaction();
                        }
                        catch (Exception exception)
                        {
                            transaction.RollbackTransaction();
                            XtraMessageBox.Show("Error : " + exception.Message, "Error...", MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                            throw exception;
                        }
                    }
                }
                BindDataSet();
                XtraMessageBox.Show("Change was Successfull", "Success...", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                return;
            }

            XtraMessageBox.Show("No Changes have been made", "No Changes...", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }