Beispiel #1
0
        private void EditIssue_Load(object sender, EventArgs e)
        {
            Stores str = new Stores();

            str.LoadAll();
            cboStores.DataSource = str.DefaultView;

            ReceivingUnits rUnit = new ReceivingUnits();

            rUnit.GetActiveDispensaries();
            cboReceivingUnit.DataSource = rUnit.DefaultView;

            if (_tranId != 0)
            {
                IssueDoc iss = new IssueDoc();
                Items    itm = new Items();


                iss.LoadByPrimaryKey(_tranId);

                DataTable dtItm    = itm.GetItemById(iss.ItemID);
                string    itemName = dtItm.Rows[0]["ItemName"].ToString() + " - " + dtItm.Rows[0]["DosageForm"].ToString() + " - " + dtItm.Rows[0]["Strength"].ToString();

                txtRefNo.Text   = iss.RefNo;
                txtBatchNo.Text = iss.BatchNo;
                try
                {
                    txtPack.Text    = iss.NoOfPack.ToString();
                    txtQtyPack.Text = iss.QtyPerPack.ToString();
                    txtPrice.Text   = (iss.Cost * iss.QtyPerPack).ToString();
                }
                catch
                {
                    txtPack.Text    = "0";
                    txtQtyPack.Text = "0";
                    txtPrice.Text   = (iss.Cost * 1).ToString();
                }
                txtQuantity.Text = iss.Quantity.ToString();
                DateTime dtDate = Convert.ToDateTime(iss.Date.ToString("MM/dd/yyyy"));
                txtDate.Text = dtDate.ToShortDateString();
                //dtIssDate.Value = DateTime.Now;
                //dtIssDate.CustomFormat = "MM/dd/yyyy";
                //DateTime dtCurrent = Convert.ToDateTime(dtIssDate.Text);

                //long tic = (DateTime.Now.Ticks - dtCurrent.Ticks);
                //DateTime dtIssG = dtDate.AddTicks(tic);

                //dtIssDate.Value = dtIssG;
                cboStores.SelectedValue        = iss.StoreId;
                cboReceivingUnit.SelectedValue = iss.ReceivingUnitID;
                txtItemName.Text   = itemName;
                txtReceivedBy.Text = iss.IssuedBy;
                txtRemark.Text     = iss.Remark;
            }
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string valid = ValidateFields();

            if (valid == "true")
            {
                if (XtraMessageBox.Show("Are You Sure, You want to save this Transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    IssueDoc   iss = new IssueDoc();
                    ReceiveDoc rec = new ReceiveDoc();

                    iss.LoadByPrimaryKey(_tranId);

                    string batchNo = iss.BatchNo;
                    Int64  qty     = iss.Quantity;
                    rec.GetTransactionByBatch(iss.ItemID, iss.BatchNo, iss.StoreId);

                    iss.RefNo           = txtRefNo.Text;
                    iss.BatchNo         = txtBatchNo.Text;
                    iss.NoOfPack        = Convert.ToInt32(txtPack.Text);
                    iss.QtyPerPack      = Convert.ToInt32(txtQtyPack.Text);
                    iss.Quantity        = Convert.ToInt32(txtPack.Text) * Convert.ToInt32(txtQtyPack.Text);
                    iss.StoreId         = Convert.ToInt32(cboStores.SelectedValue);
                    iss.ReceivingUnitID = Convert.ToInt32(cboReceivingUnit.SelectedValue);
                    iss.Remark          = txtRemark.Text;
                    iss.IssuedBy        = txtReceivedBy.Text;
                    iss.Save();

                    Int64 newQty = 0;
                    if (qty > iss.Quantity)
                    {
                        newQty = rec.QuantityLeft + (qty - iss.Quantity);
                    }
                    else
                    {
                        newQty = rec.QuantityLeft - (iss.Quantity - qty);
                    }

                    rec.QuantityLeft = newQty;
                    if (rec.QuantityLeft > 0)
                    {
                        rec.Out = false;
                    }
                    rec.Save();

                    XtraMessageBox.Show("Transaction Succsfully Saved!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            else
            {
                XtraMessageBox.Show(valid, "Validation", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
        private void unconfirmedMenuClicked_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            DataRow dataRow = gridUnconfirmedView.GetFocusedDataRow();

            if (dataRow != null)
            {
                if (e.ClickedItem.Text == "Delete")
                {
                    if (DialogResult.Yes ==
                        XtraMessageBox.Show("Are you sure you would like to delete this?", "Confirmation",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        DeleteIssueDoc(Convert.ToInt32(dataRow["ID"]));
                        // Refresh it
                        gridViewReferences_FocusedRowChanged(null, null);
                        //XtraMessageBox.Show("Issue has been deleted");
                    }
                }
                else if (e.ClickedItem.Text == "Confirm")
                {
                    IssueDoc doc = new IssueDoc();
                    doc.LoadByPrimaryKey(Convert.ToInt32(dataRow["ID"]));

                    // do some validations
                    if (doc.IsColumnNull("STVID"))
                    {
                        doc.STVID = _stvLogIdChosen.Value;
                        doc.Save();
                    }

                    // refresh
                    XtraMessageBox.Show("You have confirmed the STV", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    gridViewReferences_FocusedRowChanged(null, null);
                }
            }
        }
 public static void RecordDiscrepancy(Dictionary<int, decimal> _discrepancyIssueDoc)
 {
     foreach(int issueDocID in _discrepancyIssueDoc.Keys)
     {
         BLL.IssueDoc issueDoc = new IssueDoc();
         issueDoc.LoadByPrimaryKey(issueDocID);
         issueDoc.NoOfPackIssued = _discrepancyIssueDoc[issueDocID];
         issueDoc.Save();
     }
 }
Beispiel #5
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");
            }
        }
        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();
            }
        }
Beispiel #7
0
        private void PrintReceiptConfirmation(string referenceNumber, int?reprintOfReceiptConfirmationPrintoutID)
        {
            var rc          = new ReceiptConfirmationPrintout();
            var srmPrintout = new HCMIS.Desktop.Reports.SRMPrintout(CurrentContext.LoggedInUserName);

            int ReceiptID  = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);
            var receiveDoc = new ReceiveDoc();

            receiveDoc.LoadByReceiptID(ReceiptID);
            ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID);
            srmPrintout.BranchName.Text = GeneralInfo.Current.HospitalName;
            rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 3, null,
                                      reprintOfReceiptConfirmationPrintoutID, FiscalYear.Current);
            srmPrintout.DataSource = rc.DefaultView.ToTable();

            var rUnit = new Institution();
            var idoc  = new IssueDoc();

            if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID"))
            {
                idoc.LoadByPrimaryKey(receiveDoc.ReturnedFromIssueDocID);
                rUnit.LoadByPrimaryKey(idoc.ReceivingUnitID);
            }
            else
            {
                var po = new PO();
                po.LoadByReceiptID(receiveDoc.ReceiptID);
                rUnit.LoadByPrimaryKey(int.Parse(po.RefNo));
            }

            srmPrintout.xrFromValue.Text   = rUnit.Name;
            srmPrintout.xrWoredaValue.Text = rUnit.WoredaText;
            srmPrintout.xrRegionValue.Text = rUnit.Region;
            srmPrintout.xrZoneValue.Text   = rUnit.ZoneText;


            if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID"))
            {
                var stvLog = new BLL.Issue();
                stvLog.LoadByPrimaryKey(idoc.STVID);

                srmPrintout.xrIssueDateValue.Text = idoc.Date.ToString("M/d/yyyy");
                var activity = new Activity();
                activity.LoadByPrimaryKey(idoc.StoreId);
                srmPrintout.xrAccountName.Text = activity.FullActivityName;
                var rct = new BLL.Receipt();
                rct.LoadByPrimaryKey(ReceiptID);
                var rctInvoice = new ReceiptInvoice();
                rctInvoice.LoadByPrimaryKey(rct.ReceiptInvoiceID);
                srmPrintout.xrSTVNoValue.Text = rctInvoice.STVOrInvoiceNo;
            }
            else
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(receiveDoc.StoreID);
                srmPrintout.xrAccountName.Text = activity.FullActivityName;
                srmPrintout.xrSTVNoValue.Text  = receiveDoc.RefNo;
            }

            var dtDate = new DateTimePickerEx();

            dtDate.Value          = receiveDoc.EurDate;
            srmPrintout.Date.Text = dtDate.Text;
            if (srmPrintout.PrintDialog() != DialogResult.OK)
            {
                throw new Exception("Print cancelled by user!");
            }


            //Successfully printed

            //Release Product
            var GRV = new CostCalculator();

            GRV.LoadGRV(ReceiptID);
            GRV.ReleaseForIssue();

            String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();
            var    recDoc    = new ReceiveDoc();

            recDoc.LoadByReferenceNo(reference);
            recDoc.ConfirmGRVPrinted(CurrentContext.UserId);
            BLL.Receipt receiptStatus = new BLL.Receipt();
            receiptStatus.LoadByPrimaryKey(ReceiptID);
            receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRV_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "GRV Printed");
            BindFormContents();
        }
        /// <summary>
        /// Returns an extra report containing the GRNF.
        /// This function is used for creating the report for the first time as well (Not just export). Which is why we can't
        /// just use the overload with the ReceiptConfirmationPrintoutID as a parameter.
        /// </summary>
        /// <param name="receiptID"></param>
        /// <param name="IDPrinted">Use this if you're trying to get a GRNF printed previously using some ID</param>
        /// <param name="isDocumentBrowser">Use this For Docuement Browser </param>
        /// <returns></returns>
        public static XtraReport CreateGRNFPrintout(int receiptID, int?IDPrinted, bool isDocumentBrowser, FiscalYear fiscalYear)
        {
            ReceiptConfirmationPrintoutStore printout = new ReceiptConfirmationPrintoutStore(CurrentContext.LoggedInUserName);

            BLL.ReceiptConfirmationPrintout rc = new BLL.ReceiptConfirmationPrintout();

            printout.BranchName.Text = GeneralInfo.Current.HospitalName;
            printout.xrGRVLabel.Text = "GRNF No.";
            int printedID;

            BLL.ReceiveDoc rDoc = new ReceiveDoc();
            rDoc.LoadByReceiptID(receiptID);

            var activity = new Activity();

            activity.LoadByPrimaryKey(rDoc.StoreID);
            var supplier = new Supplier();

            supplier.LoadByPrimaryKey(rDoc.SupplierID);

            var       hsup       = new Supplier();
            DataTable homeOffice = hsup.GetHubHeadOffice();


            if (supplier.ID == (int)homeOffice.Rows[0]["SupplierID"] && !Settings.IsCenter)
            {
                printout.ReportType = ReceiptConfirmationPrintoutStore.GRNFReportType.IGRV;
            }
            else if (supplier.ID != (int)homeOffice.Rows[0]["SupplierID"])
            {
                printout.ReportType = ReceiptConfirmationPrintoutStore.GRNFReportType.GRV;
            }
            if (rDoc.RowCount == 0 && isDocumentBrowser)
            {
                rDoc.LoadDeletedByReceiptID(receiptID);
            }
            else if (rDoc.RowCount == 0)
            {
                throw new Exception("This Receipt Doesn't have corresponding Receipt Doc Entries.");
            }

            if (rDoc.ReturnedStock)
            {
                BLL.Institution ru       = new Institution();
                BLL.IssueDoc    issueDoc = new IssueDoc();
                if (!rDoc.IsColumnNull("ReturnedFromIssueDocID"))
                {
                    issueDoc.LoadByPrimaryKey(rDoc.ReturnedFromIssueDocID);
                    ru.LoadByPrimaryKey(issueDoc.ReceivingUnitID);
                }
                else
                {
                    BLL.PO po = new PO();
                    po.LoadByReceiptID(receiptID);
                    ru.LoadByPrimaryKey(Int32.Parse(po.RefNo));
                }

                printout.xrFromFacilityValue.Text = ru.Name;
                printout.ReportType = ReceiptConfirmationPrintoutStore.GRNFReportType.SRM;
            }

            // determine if this is a transfer? account to account or store to store

            Receipt receipt = new Receipt();

            receipt.LoadByPrimaryKey(receiptID);


            printedID = rc.PrepareDataForPrintout(receiptID, CurrentContext.UserId, false, 1, IDPrinted, null, fiscalYear);
            DataTable dataTable = rc.DefaultView.ToTable();

            printout.DataSource            = dataTable;
            printout.xrLabelStoreName.Text = activity.FullActivityName;

            ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation();
            DataTable Users = receiveDocConfirmation.GetUserNamebyReceipt(receiptID);

            if (Users.Rows.Count > 0)
            {
                printout.PreparedBy.Text = Users.Rows[0]["ReceivedBy"].ToString();
                printout.CheckedBy.Text  = Users.Rows[0]["ConfirmedBy"].ToString();
            }

            if (ReceiveDoc.IsThereShortageOrDamage(receiptID))
            {
                ReceiptConfirmationShortagePrintout printoutShortage =
                    new ReceiptConfirmationShortagePrintout();

                rc.PrepareDataForPrintout(receiptID, CurrentContext.UserId, true, 1, printedID, null, fiscalYear);
                printoutShortage.DataSource                     = rc.DefaultView.ToTable();
                printout.xrShortageReport.ReportSource          = printoutShortage;
                printout.PrintingSystem.ContinuousPageNumbering = true;
            }
            else
            {
                printout.ReportFooter.Visible = false;
            }



            CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
            //dtDate.CustomFormat = "dd/MM/yyyy";
            dtDate.Value       = rDoc.EurDate;
            printout.Date.Text = dtDate.Text;
            if (InstitutionIType.IsVaccine(GeneralInfo.Current))
            {
                return(CreateModel19Printout(dataTable.DefaultView.ToTable(), dtDate.Text));
            }
            return(printout);
        }
        public static XtraReport PrintReceiptConfirmation(string printedBy, int receiptID, int?previousReceiptConfirmationPrintoutID, bool forExporting, FiscalYear fiscalYear)
        {
            var rcPrevious       = new BLL.ReceiptConfirmationPrintout();
            int?idToBePrintedOut = null;

            if (forExporting && previousReceiptConfirmationPrintoutID.HasValue)
            {
                rcPrevious.LoadByPrimaryKey(previousReceiptConfirmationPrintoutID.Value);
                idToBePrintedOut = rcPrevious.IDPrinted;
            }

            var rc       = new BLL.ReceiptConfirmationPrintout();
            var printout =
                new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(printedBy);

            var srmPrintout = new HCMIS.Desktop.Reports.SRMPrintout(printedBy);

            var receiveDoc = new ReceiveDoc();
            var receipt    = new BLL.Receipt();

            receipt.LoadByPrimaryKey(receiptID);
            receiveDoc.LoadByReceiptID(receiptID);

            var referenceNumber = receiveDoc.RefNo;
            var activity        = new Activity();

            activity.LoadByPrimaryKey(receiveDoc.StoreID);
            var supplier = new Supplier();

            supplier.LoadByPrimaryKey(receiveDoc.SupplierID);
            int printedID = 0;

            string GRNFNo = fiscalYear.GetCode(BLL.ReceiptConfirmationPrintout.GetGRNFNo(receiptID));

            if (receipt.ReceiptTypeID == ReceiptType.CONSTANTS.STANDARD_RECEIPT || receipt.ReceiptTypeID == ReceiptType.CONSTANTS.DELIVERY_NOTE || receipt.ReceiptTypeID == ReceiptType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER)
            {
                if (!String.IsNullOrEmpty(GeneralInfo.Current.HospitalName))
                {
                    printout.BranchName.Text = GeneralInfo.Current.HospitalName;
                }
                else
                {
                    throw new Exception("Branch name could not be read from the database.");
                }

                PrepareGRVPrintout(printout);
                //  String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

                if (supplier.SupplierTypeID == SupplierType.CONSTANTS.HOME_OFFICE ||
                    supplier.SupplierTypeID == SupplierType.CONSTANTS.HUBS ||
                    supplier.SupplierTypeID == SupplierType.CONSTANTS.ACCOUNTS ||
                    supplier.SupplierTypeID == SupplierType.CONSTANTS.STORES)
                {
                    printout.xrGRVLabel.Text                = "iGRV No.";
                    printout.xrAir.Visible                  = false;
                    printout.xrAirValue.Visible             = false;
                    printout.xrTransit.Visible              = false;
                    printout.xrTransitValue.Visible         = false;
                    printout.xrInsurance.Visible            = false;
                    printout.xrInsuranceValue.Visible       = false;
                    printout.xrNumberOfCases.Visible        = false;
                    printout.xrNumberOfCasesValue.Visible   = false;
                    printout.xrInvoiceNo.Text               = "STV No.";
                    printout.xrPurchaseOrderNo.Visible      = false;
                    printout.xrPurchaseOrderNoValue.Visible = false;

                    printout.xrLabelGRNF.Text     = GRNFNo;
                    printout.xrSTV.Visible        = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(receiptID, CurrentContext.UserId, false, 4,
                                                          idToBePrintedOut, previousReceiptConfirmationPrintoutID, fiscalYear);
                    printout.DataSource = rc.DefaultView.ToTable();
                    var dtDate = new DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }
                else
                {
                    printout.xrGRVLabel.Text      = "GRV No.";
                    printout.xrSTV.Visible        = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(receiptID, CurrentContext.UserId, false, 2,
                                                          idToBePrintedOut, previousReceiptConfirmationPrintoutID, fiscalYear);
                    printout.xrLabelGRNF.Text = GRNFNo;
                    printout.DataSource       = rc.DefaultView.ToTable();

                    var dtDate = new DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }


                printout.xrLabelStoreName.Text = activity.FullActivityName;

                if (ReceiveDoc.IsThereShortageOrDamage(receiptID))
                {
                    ReceiptConfirmationShortagePrintout printoutShortage =
                        PrintReceiptConfirmationForShortage(receiptID, printedID, fiscalYear);

                    PrepareGRVPrintout(printoutShortage);
                    printout.xrShortageReport.ReportSource = printoutShortage;

                    printout.PrintingSystem.ContinuousPageNumbering = true;
                }
                else
                {
                    printout.ReportFooter.Visible = false;
                }
                if (!forExporting) //If this is not for exporting, we print on paper.
                {
                    if (printout.PrintDialog() != DialogResult.OK)
                    {
                        throw new Exception("Print cancelled by user!");
                    }
                }

                return(printout);
            }

            else if (receipt.ReceiptTypeID == ReceiptType.CONSTANTS.STOCK_RETURN)
            {
                if (!String.IsNullOrEmpty(GeneralInfo.Current.HospitalName))
                {
                    srmPrintout.BranchName.Text = GeneralInfo.Current.HospitalName;
                }

                rc.PrepareDataForPrintout(receiptID, CurrentContext.UserId, false, 3, idToBePrintedOut,
                                          previousReceiptConfirmationPrintoutID, fiscalYear);
                srmPrintout.DataSource = rc.DefaultView.ToTable();

                var rUnit = new Institution();
                var idoc  = new IssueDoc();
                if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID"))
                {
                    idoc.LoadByPrimaryKey(receiveDoc.ReturnedFromIssueDocID);
                    rUnit.LoadByPrimaryKey(idoc.ReceivingUnitID);
                }
                else
                {
                    var po = new PO();
                    po.LoadByReceiptID(receiveDoc.ReceiptID);
                    rUnit.LoadByPrimaryKey(int.Parse(po.RefNo));
                }

                srmPrintout.xrFromValue.Text   = rUnit.Name;
                srmPrintout.xrWoredaValue.Text = rUnit.WoredaText;
                srmPrintout.xrRegionValue.Text = rUnit.Region;
                srmPrintout.xrZoneValue.Text   = rUnit.ZoneText;

                if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID"))
                {
                    var stvLog = new Issue();
                    stvLog.LoadByPrimaryKey(idoc.STVID);
                    var issuedActivity = new Activity();
                    issuedActivity.LoadByPrimaryKey(idoc.StoreId);
                    srmPrintout.xrAccountName.Text = issuedActivity.FullActivityName;
                    srmPrintout.xrSTVNoValue.Text  = stvLog.IDPrinted.ToString("00000");
                }
                else
                {
                    srmPrintout.xrAccountName.Text = activity.FullActivityName;;
                    srmPrintout.xrSTVNoValue.Text  = receiveDoc.RefNo;
                }

                var dtDate = new DateTimePickerEx();
                dtDate.Value          = receiveDoc.EurDate;
                srmPrintout.Date.Text = dtDate.Text;

                if (!forExporting)
                {
                    if (srmPrintout.PrintDialog() != DialogResult.OK)
                    {
                        throw new Exception("Print cancelled by user!");
                    }
                }
                return(srmPrintout);
            }

            else //TODO: Implement Delivery notes.
            {
                return(null);
            }
        }
Beispiel #10
0
        private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            var us     = new User();
            var userID = MainWindow.LoggedinId;

            us.LoadByPrimaryKey(userID);

            DataRow dr = grdLogIssue.GetFocusedDataRow();

            if (dr == null)
            {
                return;
            }

            int tranId = Convert.ToInt32(dr["ID"]);
            var rec    = new ReceiveDoc();
            var iss    = new IssueDoc();

            iss.LoadByPrimaryKey(tranId);

            string batchNo = iss.BatchNo;

            try
            {
                if (iss.RecievDocID.ToString() != "")
                {
                    rec.LoadByPrimaryKey(iss.RecievDocID);
                }
                else
                {
                    rec.GetTransactionByBatch(iss.ItemID, iss.BatchNo, iss.StoreId);
                }
            }
            catch
            {
                rec.GetTransactionByBatch(iss.ItemID, iss.BatchNo, iss.StoreId);
            }

            if (batchNo != rec.BatchNo && batchNo != string.Empty)
            {
                XtraMessageBox.Show("Unable to Delete, This Transaction has been processed. Try Loss and Adjustment.", "Unable to Delete", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
            else if (batchNo == string.Empty || batchNo == rec.BatchNo)
            {
                if (XtraMessageBox.Show("Are You Sure, You want to delete this Transaction? You will not be able to restore this data.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    rec.QuantityLeft = rec.QuantityLeft + iss.Quantity;
                    if (rec.QuantityLeft > 0)
                    {
                        rec.Out = false;
                    }
                    rec.Save();
                    AddIssueLodDelete(iss);
                    DeletedRelatedModel(iss);
                    iss.MarkAsDeleted();
                    iss.Save();

                    DataTable dtRec = iss.GetAllTransaction(Convert.ToInt32(cboStores.EditValue));
                    gridIssues.DataSource = dtRec;
                }
            }
        }
Beispiel #11
0
        public void DeleteAnIssue(int issueDociD)
        {
            ReceiveDoc    rdoc = new ReceiveDoc();
            ReceivePallet rp   = new ReceivePallet();
            IssueDoc      idoc = new IssueDoc();

            idoc.LoadByPrimaryKey(issueDociD);

            if (idoc.IsThereSRM)
            {
                throw new Exception("There is an SRM for this issue.  You can't void it.");
            }

            PickListDetail pld = new PickListDetail();

            //pld.LoadByOrderAndItem(idoc.OrderID, idoc.ItemID, idoc.NoOfPack);
            pld.LoadByPrimaryKey(idoc.PLDetailID);

            string RefNo = idoc.RefNo;

            rdoc.LoadByPrimaryKey(idoc.RecievDocID);

            //if (pld.RowCount == 0)
            //{
            //    pld.LoadByOrderAndItem(idoc.OrderID, idoc.ItemID);
            //}

            rp.LoadByReceiveDocID(idoc.RecievDocID);
            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();
                }
            }


            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;

                //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)
                {
                    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();
                    pld.Save();
                }
                else
                {
                    XtraMessageBox.Show(
                        "This delete is not successful 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);
                }
            }
        }