示例#1
0
        private void _reload()
        {
            datestart.Value = DateTime.Now;
            dateend.Value   = DateTime.Now.AddDays(14);
            var lst = new List <KeyValuePair <string, string> >();

            lst.Add(new KeyValuePair <string, string>(null, "Tất cả"));
            lst.Add(new KeyValuePair <string, string>("ACTIVE", "Đã xác nhận"));
            lst.Add(new KeyValuePair <string, string>("CONFIRM", "Chờ xác nhận"));
            lst.Add(new KeyValuePair <string, string>("DONE", "Đã khám"));
            lst.Add(new KeyValuePair <string, string>("CANCLE", "Đã hủy"));
            cmbTrangThai.BindDataSource(lst, q => q.Key, q => q.Value);
            cmbTrangThai.SelectedIndex = 2;

            var pk = new PhongKhamsBUS(this).GetAll();

            pk.Insert(0, new PhongBanDTO
            {
                IDPhongBan  = 0,
                TenPhongBan = "Tất cả"
            });
            cmbPhongKham.BindDataSource(pk, q => q.IDPhongBan, q => q.TenPhongBan);
            cmbPhongKham.SelectedIndex = 0;

            _fillter();
        }
        private void _reload()
        {
            var src  = new PhongKhamsBUS(this).GetSource();
            var have = new PhongKhamsBUS(this).GetAll();

            src = src.Where(q => !have.Any(a => a.PhongBan_Id == q.PhongBan_Id)).ToList();
            cmbPhongBan.BindItems(src, q => q.TenPhongBan);

            mDataGridView1.DataSource = new PhongKhamsBUS(this).GetAll();
        }
        private void _fillter()
        {
            var obj = cmbPhongKham.SelectedItem as PhongBanDTO;

            if (obj != null)
            {
                var       date  = dateDate.Value;
                var       lich  = new LichLamViecsBUS().GetByIDPhongBan(obj.IDPhongBan, date);
                var       bacsi = new PhongKhamsBUS(this).GetDoctorByPhongKham(obj.IDPhongBan);
                DataTable table = new DataTable();

                table.Columns.Add(new DataColumn("BS", typeof(string)));
                table.Columns.Add(new DataColumn("ID_BS", typeof(int)));
                foreach (var item in _lstTimeSlot)
                {
                    table.Columns.Add(item.IDTimeSlot.ToString(), typeof(int));
                    table.Columns.Add($"{item.Name} ({item.HourStart?.ToString("hh\\:mm")} - {item.HourEnd?.ToString("hh\\:mm")})", typeof(bool));
                }

                foreach (var item in bacsi)
                {
                    var row = table.NewRow();
                    row[0] = item.FullName; //BS
                    row[1] = item.IDDoctor; //IDBS

                    var bybs = lich.Where(q => q.NhanVien_Id == item.IDDoctor);
                    for (int i = 2; i < table.Columns.Count; i += 2)
                    {
                        int id_timeslot = int.Parse(table.Columns[i].ColumnName);
                        var tr          = bybs.FirstOrDefault(q => q.IDTimeSlot == id_timeslot);
                        row[i]     = tr?.IDLich ?? 0; // id
                        row[i + 1] = tr != null;      // checkbox
                    }

                    table.Rows.Add(row);
                }

                mDataGridView1.DataSource = table;

                mDataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                mDataGridView1.Columns[1].Visible      = false;
                for (int i = 2; i < mDataGridView1.Columns.Count; i += 2)
                {
                    mDataGridView1.Columns[i].Visible = false;
                }
                SetStatus();
            }
        }