示例#1
0
        private void gridReceiveView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            // Bind the detail grid
            PalletLocation pl = new PalletLocation();

            if (e != null && e.PrevFocusedRowHandle < -1)
            {
                return;
            }

            try
            {
                DataRow dr = gridReceiveView.GetFocusedDataRow();

                if (dr == null)
                {
                    return;
                }

                ReceiptID = Convert.ToInt32(dr["ReceiptID"]);
                BLL.Receipt receiptDoc = new BLL.Receipt();
                receiptDoc.LoadByPrimaryKey(ReceiptID);

                DataTable GRNFDetail = receiptDoc.GetDetailsForGRNF();


                if (GRNFDetail.Rows.Count > 0)
                {
                    //var store = new Store();
                    //store.
                    BLL.PO order = new BLL.PO();
                    //var Mode = new Mode();
                    //Mode.LoadByPrimaryKey(order.ModeID);
                    //lblMode.Text = Mode.TypeName;
                    HeaderSection.Text = GRNFDetail.Rows[0]["PONumber"].ToString();


                    lblRecieveStatus.Text     = dr["recieveStatus"].ToString();
                    lblReceiptNo.Text         = dr["ReceiptNo"].ToString();
                    lblRecievedBy.Text        = dr["ReceivedBy"].ToString();
                    lblRecievedDate.Text      = Convert.ToDateTime(dr["Date"]).ToShortDateString();
                    lblReciveType.Text        = (dr["ReceiveType"]).ToString();
                    lblWayBill.Text           = (dr["WayBillNo"]).ToString() != "" ? dr["WayBillNo"].ToString() : "-";
                    lblTransferVoucherNo.Text = (dr["transferNo"]).ToString() != "" ? dr["transferNo"].ToString() : "-";

                    var warehouse = new BLL.Warehouse();
                    warehouse.LoadByPrimaryKey(receiptDoc.WarehouseID);
                    lblWarehouse.Text = warehouse.Name;
                    lblSupplier.Text  = dr["Supplier"].ToString();

                    var cluster = new BLL.Cluster();
                    cluster.LoadByPrimaryKey(warehouse.ClusterID);
                    lblCluster.Text = cluster.Name;



                    lblDocType.Text = "";

                    lblPoType.Text = dr["POType"].ToString();
                    //var ps = new BLL.PhysicalStore();
                    //ps.LoadByPrimaryKey(order.p);
                    //lblStore.Text = ps.Name;


                    txtOrderNo.EditValue = GRNFDetail.Rows[0]["PONumber"];
                    lblPoNumber.Text     = GRNFDetail.Rows[0]["PONumber"].ToString();

                    lblInvoiceNumber.Text = receiptDoc.STVOrInvoiceNo;

                    lblInsurancePolicy.Text = receiptDoc.InsurancePolicyNo != ""?receiptDoc.InsurancePolicyNo : "-";

                    var activity = new Activity();
                    activity.LoadByPrimaryKey(Convert.ToInt32(GRNFDetail.Rows[0]["ActivityID"]));

                    txtActivity.EditValue = activity.FullActivityName;
                    lblActivity.Text      = activity.Name;

                    lblSubAccount.Text = activity.SubAccountName;
                    lblMode.Text       = activity.ModeName;
                    lblAccount.Text    = activity.AccountName;

                    gridDetails.DataSource = GRNFDetail;
                }

                if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
                {
                    gridShortage.DataSource = receiptDoc.GetDiscrepancyForGRNF();
                }
            }

            catch
            {
                gridDetails.DataSource = null;
            }
        }
示例#2
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);
        }