Пример #1
0
 private void LayDanhSachCacPhieuCanCapMa()
 {
     this.lstCanDanhMa.Clear();
     this.lstDonViCanCapMa.Clear();
     this.lstCanDanhMaFull.Clear();
     int[] lstChecked = this.GVDanhSachCho.GetSelectedRows();
     foreach (var index in lstChecked)
     {
         if (index >= 0)
         {
             string maChiDinh = this.GVDanhSachCho.GetRowCellValue(index, this.col_MaChiDinh_GCDanhSachCho).ToString();
             string maGoiXN   = this.GVDanhSachCho.GetRowCellValue(index, this.col_MaGoiXN).ToString();
             var    cd        = BioNet_Bus.GetThongTinhChiDinh(maChiDinh);
             if (cd != null)
             {
                 this.lstCanDanhMaFull.Add(cd);
                 if (!maChiDinh.Substring(0, 2).Equals("XN"))
                 {
                     this.lstCanDanhMa.Add(cd);
                 }
             }
         }
     }
     if (this.lstCanDanhMa.Count > 0)
     {
         var lst = this.lstCanDanhMa.GroupBy(p => p.MaDonVi).Select(r => new { maDonVi = r.Key, soLuong = r.Count(), soBatDau = 0 }).ToList();
         this.lstCapMaTheoDonVi.Clear();
         int bd = 1;
         try
         {
             bd = int.Parse(BioNet_Bus.GetMaXNTrongBangGhi()) + 1;
         }
         catch
         {
         }
         foreach (var item in lst)
         {
             PsDanhSachCapMa cm = new PsDanhSachCapMa();
             cm.maDonVi   = item.maDonVi;
             cm.soLuong   = item.soLuong;
             cm.soBatDau  = bd;
             cm.soKetThuc = bd + item.soLuong - 1;
             bd          += item.soLuong;
             this.lstDonViCanCapMa.Add(item.maDonVi);
             this.lstCapMaTheoDonVi.Add(cm);
         }
         this.maKT = bd - 1;
     }
     //for (int i = 0; i < this.GVDanhSachCho.RowCount; i++)
     //{
     //        try
     //        {
     //           // if(this.GVDanhSachCho.GetRowCellValue(i))
     //        }
     //        catch { }
     //    }
 }