Example #1
0
        public frmPrintBarcode(frmPrintBarcode _barcode) {
            try 
            {
                InitializeComponent();
                splashScreenManager1.ShowWaitForm();
                this.pBarocde = _barcode;
                sBundleTicket report = new sBundleTicket();
                rptBarcodeList s = new rptBarcodeList();
                OprationBarcodeList list = new OprationBarcodeList();

               //report.SetDataSource(list.StickerBarcodeList(pBarocde.Options, pBarocde.CutNo, pBarocde.From, pBarocde.To));

               //this.crystalReportViewer1.ReportSource = report;

                BarcodeLabel lbl = new BarcodeLabel();
                lbl.DataSource = list.StickerBarcodeList(pBarocde.Options, pBarocde.CutNo, pBarocde.From, pBarocde.To);
                ReportPrintTool tool = new ReportPrintTool(lbl);
                tool.ShowPreview();


                splashScreenManager1.CloseWaitForm();
            }catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
                Debug.WriteLine(ex.Message);
            }
           
          
          
        }
      public List<OprationBarcodeList> BarcodeList(int _key) {

          try {

              GenaricRepository<OprationBarcodes> _OprationBarcodesRepository = new GenaricRepository<OprationBarcodes>(new ItrackContext());

              var barcodes = from item in _OprationBarcodesRepository.GetAll().ToList()  where item.BundleDetails.BundleHeader.CuttingItemID == _key orderby item.OprationBarcodesID select item;
              Debug.WriteLine(barcodes.Count());
              int i = 0 ;
              OprationBarcodeList oList = new OprationBarcodeList();
              
              foreach (var barcode in barcodes) {
                
                  
                  if (_isNewRow == true) {
                      i = 0;
                   
                  }
                  if (i == 0) {

                      // left side of sticker 
                      oList.CutTicketNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeaderID;
                      oList.StyleNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeader.StyleID;
                      oList.StyleNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeader.StyleID;
                      oList.Color = barcode.BundleDetails.BundleHeader.CuttingItem.Color;
                      oList.Size = barcode.BundleDetails.BundleHeader.CuttingItem.Size;
                      oList.BundleNo = Convert.ToString(barcode.BundleDetails.BundleDetailsID);
                      oList.PartName = barcode.PartName;
                      oList.NoOfPts = Convert.ToString(barcode.BundleDetails.NoOfItem);
                      oList.OprationNo = barcode.OprationNO;
                      oList.OprationName = barcode.OparationName;
                      oList.OprationType = barcode.OprationGrade;
                      oList.OpRole = barcode.OprationRole;
                      oList.Barcode = barcode.OprationBarcodesID;
                      _isNewRow = false;
                  
                  }
              
                  //right slide of sheet 
                 if (i != 0)
                 {

                                 if (barcode.PartName != oList.PartName)
                                 {
                                     // if part not same 
                                     oList.Barcode2 = "";
                                     oList.OprationNo2 = "";
                                     oList.OprationName2 = "";

                                     _isBreackRequired = true;


                                     lstBarcodes.Add(new OprationBarcodeList(
                                             oList.CutTicketNo,
                                             oList.StyleNo,
                                             oList.StyleNo,
                                             oList.Color,
                                             oList.Size,
                                             oList.BundleNo,
                                             oList.PartName,
                                             oList.NoOfPts,
                                             oList.OprationNo,
                                             oList.OprationName,
                                             oList.OprationType,
                                             barcode.OprationRole,
                                              "*" + oList.Barcode + "*",
                                             "",
                                             oList.Barcode2,
                                             oList.OprationNo2,
                                             oList.OprationName2

                                         ));






                                     //assign as left side of new part 

                                     // left side of sticker 
                                     oList.CutTicketNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeaderID;
                                     oList.StyleNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeader.StyleID;
                                     oList.StyleNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeader.StyleID;
                                     oList.Color = barcode.BundleDetails.BundleHeader.CuttingItem.Color;
                                     oList.Size = barcode.BundleDetails.BundleHeader.CuttingItem.Size;
                                     oList.BundleNo = Convert.ToString(barcode.BundleDetails.BundleDetailsID);
                                     oList.PartName = barcode.PartName;
                                     oList.NoOfPts = Convert.ToString(barcode.BundleDetails.NoOfItem);
                                     oList.OprationNo = barcode.OprationNO;
                                     oList.OprationName = barcode.OparationName;
                                     oList.OprationType = barcode.OprationGrade;
                                     oList.OpRole = barcode.OprationRole;
                                     oList.Barcode =  barcode.OprationBarcodesID ;




                                 }
                                 else
                                 {

                                                     // if part same 
                                                     oList.Barcode2 = "*" + barcode.OprationBarcodesID + "*";
                                                     oList.OprationNo2 = barcode.OprationNO;
                                                     oList.OprationName2 = barcode.OparationName;
                                                     lstBarcodes.Add(new OprationBarcodeList(
                                                oList.CutTicketNo,
                                                oList.StyleNo,
                                                oList.StyleNo,
                                                oList.Color,
                                                oList.Size,
                                                oList.BundleNo,
                                                oList.PartName,
                                                oList.NoOfPts,
                                                oList.OprationNo,
                                                oList.OprationName,
                                                oList.OprationType,
                                                barcode.OprationRole,
                                                "*" + oList.Barcode + "*",
                                                "",
                                                oList.Barcode2,
                                                oList.OprationNo2,
                                                oList.OprationName2

                                            ));

                                                     _isNewRow = true;

                                 }
                  


                    

                   
                    
                 }

                 i = 1;
             

                  
                  /*

                  lstBarcodes.Add(new OprationBarcodeList( 
                      barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeaderID,
                      barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeader.StyleID,
                      barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeader.StyleID,
                      barcode.BundleDetails.BundleHeader.CuttingItem.Color,
                      barcode.BundleDetails.BundleHeader.CuttingItem.Size,
                      Convert.ToString( barcode.BundleDetails.BundleDetailsID),
                      barcode.PartName,
                      Convert.ToString( barcode.BundleDetails.NoOfItem),
                      barcode.OprationNO,
                      barcode.OparationName,
                      barcode.OprationGrade,
                      barcode.OprationRole,
                      "*"+barcode.OprationBarcodesID+"*",


                  )); */
              }


              return lstBarcodes;
          }
          catch(Exception ex){

              Debug.WriteLine(ex.Message);
              return null;
          }
      }
      public List<OprationBarcodeList> StickerBarcodeList(int _key,int _cutId,int _from ,int _to)
      {
          try
          {
              GenaricRepository<OprationBarcodes> _OprationBarcodesRepository = new GenaricRepository<OprationBarcodes>(new ItrackContext());
              int i = 0;
              OprationBarcodeList oList = new OprationBarcodeList();
              if (_key == 1)
              {
                  var barcodes = from item in _OprationBarcodesRepository.GetAll().ToList() where item.BundleDetails.BundleHeader.CuttingItem.CuttingItemID == _cutId orderby item.OprationBarcodesID select item;
                  foreach (var barcode in barcodes)
                  {

                      oList.CutTicketNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeaderID;
                      oList.StyleNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeader.StyleID;
                      oList.StyleNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeader.StyleID;
                      oList.Color = barcode.BundleDetails.BundleHeader.CuttingItem.Color;
                      oList.Size = barcode.BundleDetails.BundleHeader.CuttingItem.Size;
                      oList.BundleNo = Convert.ToString(barcode.BundleDetails.BundleNo);
                      oList.PartName = barcode.PartName;
                      oList.NoOfPts = Convert.ToString(barcode.BundleDetails.NoOfItem);
                      oList.OprationNo = Convert.ToString(barcode.OpNo);
                      oList.OprationName = barcode.OparationName;
                      oList.OprationType = barcode.BundleDetails.BundleHeader.CuttingItem.MarkerNo;
                      oList.OpRole = barcode.OprationRole;
                      oList.Barcode = barcode.OprationBarcodesID;
                      oList.Barcode2 = "";
                      oList.OprationNo2 = Convert.ToString(barcode.OpNo);
                      oList.OprationName2 = barcode.OparationName;
                      lstBarcodes.Add(new OprationBarcodeList(
                      oList.CutTicketNo,
                      oList.StyleNo,
                      oList.StyleNo,
                      oList.Color,
                      oList.Size,
                      oList.BundleNo,
                      oList.PartName,
                      oList.NoOfPts,
                      oList.OprationNo,
                      oList.OprationName,
                      oList.OprationType,
                      barcode.OprationRole,
                 "*" + oList.Barcode + "*",
                 "",
                     oList.Barcode2,
                     oList.OprationNo2,
                     oList.OprationName2

             ));



                  }
              }
              else if (_key == 2)
              {
                  var barcodes = from item in _OprationBarcodesRepository.GetAll().ToList() where item.BundleDetails.BundleHeader.CuttingItem.CuttingItemID >= _from && item.BundleDetails.BundleHeader.CuttingItem.CuttingItemID <= _to orderby item.OprationBarcodesID select item;
                  foreach (var barcode in barcodes)
                  {

                      oList.CutTicketNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeaderID;
                      oList.StyleNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeader.StyleID;
                      oList.StyleNo = barcode.BundleDetails.BundleHeader.CuttingItem.CuttingHeader.StyleID;
                      oList.Color = barcode.BundleDetails.BundleHeader.CuttingItem.Color;
                      oList.Size = barcode.BundleDetails.BundleHeader.CuttingItem.Size;
                      oList.BundleNo = Convert.ToString(barcode.BundleDetails.BundleNo);
                      oList.PartName = barcode.PartName;
                      oList.NoOfPts = Convert.ToString(barcode.BundleDetails.NoOfItem);
                      oList.OprationNo =Convert.ToString( barcode.OpNo);
                      oList.OprationName = barcode.OparationName;
                      oList.OprationType = barcode.OprationGrade;
                      oList.OpRole = barcode.OprationRole;
                      oList.Barcode = barcode.OprationBarcodesID;
                      oList.Barcode2 = "";
                      oList.OprationNo2 = Convert.ToString(barcode.OpNo); 
                      oList.OprationName2 = barcode.OparationName;
                      lstBarcodes.Add(new OprationBarcodeList(
                      oList.CutTicketNo,
                      oList.StyleNo,
                      oList.StyleNo,
                      oList.Color,
                      oList.Size,
                      oList.BundleNo,
                      oList.PartName,
                      oList.NoOfPts,
                      oList.OprationNo,
                      oList.OprationName,
                      oList.OprationType,
                      barcode.OprationRole,
                 "*" + oList.Barcode + "*",
                 "",
                     oList.Barcode2,
                     oList.OprationNo2,
                     oList.OprationName2

             ));



                  }
              }
            
              
             

             

              return lstBarcodes;

          }
          catch (Exception ex)
          {
              Debug.WriteLine(ex.Message);
              return null;
          }

      }