private void gridOrderListView_FocusedRowChanged(object sender,
                                                         DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            DataRow dr = gridOrderListView.GetFocusedDataRow();
            if (dr != null)
            {
                int receiptID = Convert.ToInt32(dr["ID"]);
                ReceiveDoc receiveDoc = new ReceiveDoc();
                receiveDoc.LoadAllByReceiptID(receiptID);
                DataTable tbl = receiveDoc.DefaultView.ToTable();
                ReceiveDocDeleted receiveDocDeleted = new ReceiveDocDeleted();
                receiveDocDeleted.LoadAllByReceiptID(receiptID);

                LogReceiptStatus logReceiptStatus = new LogReceiptStatus();
                gridHistory.DataSource = logReceiptStatus.GetLogHistory(receiptID);

                if (receiveDocDeleted.RowCount > 0)
                {
                    tbl.Merge(receiveDocDeleted.DefaultView.ToTable());
                    BLL.User user = new User();
                    user.LoadByPrimaryKey(receiveDocDeleted.DeletedBy);
                    if (user.RowCount > 0)
                    {
                        lblDeletedBy.Text = string.Format("Deleted By {0}",
                                                          string.IsNullOrEmpty(user.FullName)
                                                              ? user.UserName
                                                              : user.FullName);
                    }
                }

                gridOrderDetail.DataSource = tbl;
            }
        }
Exemplo n.º 2
0
        public void SaveCostCoefficient(int userID)
        {
            ReceiveDoc grvFullDetail = new ReceiveDoc();

            grvFullDetail.FlushData();
            grvFullDetail.LoadAllByReceiptID(GRV.ID);
            CostBuildUp.SaveChange();
            while (!grvFullDetail.EOF)
            {
                //Insurance here is costCoefficient
                ReceiveDoc receivedoc = new ReceiveDoc();
                receivedoc.LoadByPrimaryKey(grvFullDetail.ID);
                //Use Custom StoreProcedure for Costing
                receivedoc.Insurance = CostCoefficient;
                receivedoc.Save();
                ReceiveDoc.SetUnitCostByReceiveDoc(grvFullDetail.ID, Math.Round(receivedoc.PricePerPack * CostCoefficient, 2), userID);
                ReceiveDoc.SetAverageCostByReceiveDoc(grvFullDetail.ID, Math.Round(receivedoc.PricePerPack * CostCoefficient, 2), userID);
                grvFullDetail.MoveNext();
            }
        }
        public void SaveCostCoefficientAndTotalValue(int userID)
        {
            ReceiveDoc grvFullDetail = new ReceiveDoc();
               grvFullDetail.FlushData();
               grvFullDetail.LoadAllByReceiptID(GRV.ID);

               while (!grvFullDetail.EOF)
               {
                  //Insurance here is costCoefficient
                ReceiveDoc receivedoc = new ReceiveDoc();
                receivedoc.LoadByPrimaryKey(grvFullDetail.ID);
                //Use Custom StoreProcedure for Costing
                receivedoc.Insurance = CostCoefficient;
                receivedoc.Save();
                ReceiveDoc.SetUnitCostByReceiveDoc(grvFullDetail.ID,Math.Round(receivedoc.PricePerPack * CostCoefficient,2),userID);
                ReceiveDoc.SetAverageCostByReceiveDoc(grvFullDetail.ID,Math.Round(receivedoc.PricePerPack * CostCoefficient,2),userID);
                grvFullDetail.MoveNext();
               }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="refNo"></param>
        /// <param name="userID"></param>
        /// <param name="shortageAndDamage"></param>
        /// <param name="preGRVOrGRVOrSRM">1-PreGRV, 2-GRV, 3-SRM, 4-iGRV, 5-DeliveryNote</param>
        /// <param name="IDToBePrintedOut">Only applicable for the shortage where we need to show the same ID</param>
        /// <returns></returns>
        public int PrepareDataForPrintout(int ReceiptID, int? userID, bool shortageAndDamage, int preGRVOrGRVOrSRM, int? IDToBePrintedOut, int? isReprintOfRCPrintoutID,FiscalYear fiscalYear)
        {
            string query = "";

            if (!shortageAndDamage && preGRVOrGRVOrSRM != 3)
            {
                query =
                    HCMIS.Repository.Queries.ReceiptConfirmationPrintout.SelectPrepareDataForPrintout(ReceiptID, StorageType.Quaranteen);
            }
            else if (preGRVOrGRVOrSRM == 3)//SRM
            {
                BLL.ReceiveDoc rd = new ReceiveDoc();
                rd.LoadAllByReceiptID(ReceiptID);
                if (rd.IsColumnNull("ReturnedFromIssueDocID")) //This is an SRM done for an issue from the old system. (The issue was done using the old system)
                {
                    query = HCMIS.Repository.Queries.ReceiptConfirmationPrintout.SelectPrepareDataForPrintoutIssueDone(ReceiptID);
                }
                else //This is a normal SRM (Both the issue and the receive were done using this system)
                {
                    query = HCMIS.Repository.Queries.ReceiptConfirmationPrintout.SelectPrepareDataForPrintoutIssueAndReceiveDone(ReceiptID);

                }
            }
            else
            {
                //Cost Calculations should be removed from the query below
                query = HCMIS.Repository.Queries.ReceiptConfirmationPrintout.SelectPrepareDataForPrintout(ReceiptID);
            }
            this.LoadFromRawSql(query);

            if (this.RowCount == 0)
            {
                if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
                {
                    query = HCMIS.Repository.Queries.ReceiptConfirmationPrintout.SelectPrepareDataForPrintout(ReceiptID);
                    this.LoadFromRawSql(query);
                }
                if (this.RowCount == 0)
                    throw new Exception("No Data To Print, please receive Document before Trying again");

            }

            this.Rewind();

            this.AddColumn("LineNum", typeof(int));
            this.AddColumn("PrintedGRVNumber", typeof(string));

            BLL.Receipt receipt = new Receipt();
            int receiptID = int.Parse(this.GetColumn("ReceiptID").ToString());
            receipt.LoadByPrimaryKey(receiptID);

            int receiptTypeID = receipt.ReceiptTypeID;
            int printedGRVNumber;
            int lineNum = 1;
            int totalItems = 0;

            BLL.ReceiptConfirmationPrintout rcp = new ReceiptConfirmationPrintout();
            int? supplierID = null;
            if (preGRVOrGRVOrSRM != 3)
                supplierID = this.SupplierID;
            if (IDToBePrintedOut.HasValue)
            {
                printedGRVNumber = IDToBePrintedOut.Value;
            }
            else
            {
               printedGRVNumber = rcp.AddNew(this.StoreID, supplierID, receiptTypeID == 2 ? null : userID, receipt.ID,
                           preGRVOrGRVOrSRM, isReprintOfRCPrintoutID);
            }

            if (!IDToBePrintedOut.HasValue) //We want to save a new receipt confirmation printout only when a new ID is generated (Not when an ID to be printed has been passed as a parameter)
            {
                 //For delivery note only, we don't save the saved by user id so that we don't say GRV has been printed.
            }

            while (!this.EOF)
            {
                this.SetColumn("LineNum", lineNum);
                lineNum++;
                this.SetColumn("PrintedGRVNumber", fiscalYear.GetCode(printedGRVNumber));

                totalItems++;
                this.MoveNext();
            }

            return  printedGRVNumber;
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="refNo"></param>
        /// <param name="userID"></param>
        /// <param name="shortageAndDamage"></param>
        /// <param name="preGRVOrGRVOrSRM">1-PreGRV, 2-GRV, 3-SRM, 4-iGRV, 5-DeliveryNote</param>
        /// <param name="IDToBePrintedOut">Only applicable for the shortage where we need to show the same ID</param>
        /// <returns></returns>
        public int PrepareDataForPrintout(int ReceiptID, int?userID, bool shortageAndDamage, int preGRVOrGRVOrSRM, int?IDToBePrintedOut, int?isReprintOfRCPrintoutID, FiscalYear fiscalYear)
        {
            string query = "";


            if (!shortageAndDamage && preGRVOrGRVOrSRM != 3)
            {
                query =
                    HCMIS.Repository.Queries.ReceiptConfirmationPrintout.SelectPrepareDataForPrintout(ReceiptID, StorageType.Quaranteen);
            }
            else if (preGRVOrGRVOrSRM == 3)//SRM
            {
                BLL.ReceiveDoc rd = new ReceiveDoc();
                rd.LoadAllByReceiptID(ReceiptID);
                if (rd.IsColumnNull("ReturnedFromIssueDocID")) //This is an SRM done for an issue from the old system. (The issue was done using the old system)
                {
                    query = HCMIS.Repository.Queries.ReceiptConfirmationPrintout.SelectPrepareDataForPrintoutIssueDone(ReceiptID);
                }
                else //This is a normal SRM (Both the issue and the receive were done using this system)
                {
                    query = HCMIS.Repository.Queries.ReceiptConfirmationPrintout.SelectPrepareDataForPrintoutIssueAndReceiveDone(ReceiptID);
                }
            }
            else
            {
                //Cost Calculations should be removed from the query below
                query = HCMIS.Repository.Queries.ReceiptConfirmationPrintout.SelectPrepareDataForPrintout(ReceiptID);
            }
            this.LoadFromRawSql(query);

            if (this.RowCount == 0)
            {
                if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
                {
                    query = HCMIS.Repository.Queries.ReceiptConfirmationPrintout.SelectPrepareDataForPrintout(ReceiptID);
                    this.LoadFromRawSql(query);
                }
                if (this.RowCount == 0)
                {
                    throw new Exception("No Data To Print, please receive Document before Trying again");
                }
            }

            this.Rewind();

            this.AddColumn("LineNum", typeof(int));
            this.AddColumn("PrintedGRVNumber", typeof(string));

            BLL.Receipt receipt   = new Receipt();
            int         receiptID = int.Parse(this.GetColumn("ReceiptID").ToString());

            receipt.LoadByPrimaryKey(receiptID);

            int receiptTypeID = receipt.ReceiptTypeID;
            int printedGRVNumber;
            int lineNum    = 1;
            int totalItems = 0;

            BLL.ReceiptConfirmationPrintout rcp = new ReceiptConfirmationPrintout();
            int?supplierID = null;

            if (preGRVOrGRVOrSRM != 3)
            {
                supplierID = this.SupplierID;
            }
            if (IDToBePrintedOut.HasValue)
            {
                printedGRVNumber = IDToBePrintedOut.Value;
            }
            else
            {
                printedGRVNumber = rcp.AddNew(this.StoreID, supplierID, receiptTypeID == 2 ? null : userID, receipt.ID,
                                              preGRVOrGRVOrSRM, isReprintOfRCPrintoutID);
            }


            if (!IDToBePrintedOut.HasValue) //We want to save a new receipt confirmation printout only when a new ID is generated (Not when an ID to be printed has been passed as a parameter)
            {
                //For delivery note only, we don't save the saved by user id so that we don't say GRV has been printed.
            }

            while (!this.EOF)
            {
                this.SetColumn("LineNum", lineNum);
                lineNum++;
                this.SetColumn("PrintedGRVNumber", fiscalYear.GetCode(printedGRVNumber));

                totalItems++;
                this.MoveNext();
            }

            return(printedGRVNumber);
        }
        private HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout PrintReceiptConfirmationForShortage(int ReceiptID, int printedID)
        {
            HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout();
               ReceiptConfirmationPrintout rc = new ReceiptConfirmationPrintout();

            BLL.ReceiveDoc receiveDoc = new ReceiveDoc();
            receiveDoc.LoadAllByReceiptID(ReceiptID);

            if (currentMode == Modes.GRVPrinting )
            {
                BLL.Supplier supplier = new Supplier();
                supplier.LoadByPrimaryKey(receiveDoc.SupplierID);
            }
            rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, true, 2, printedID,null,FiscalYear.Current);
            printout.DataSource = rc.DefaultView.ToTable();
            return printout;
        }