コード例 #1
0
        private void DataGridView2Config(ViewSapXepLichTrinh viewSapXepLichTrinh)
        {
            //dataGridView2.Refresh();
            ATINChamCongEntities context = new ATINChamCongEntities();
            var lstSapXepLTT             = context.spGetSapXepLichTrinhTamByNguoi(viewSapXepLichTrinh.MaNguoi).ToList();
            var lstLichTrinh             = context.spGetAllLichTrinh().ToList();

            dataGridView2.DataSource = lstSapXepLTT;
            if (lstSapXepLTT.Count < 1)
            {
                return;
            }
            dataGridView2.Columns["TuNgay"].DisplayIndex       = 0;
            dataGridView2.Columns["DenNgay"].DisplayIndex      = 1;
            dataGridView2.Columns["TenLichTrinh"].DisplayIndex = 2;

            foreach (DataGridViewRow row in dataGridView2.Rows)
            {
                foreach (var lichtrinh in lstLichTrinh)
                {
                    if ((row.DataBoundItem as SapXepLichTrinhTam).MaLichTrinh == lichtrinh.MaLichTrinh)
                    {
                        row.Cells["TenLichTrinh"].Value = lichtrinh.TenLichTrinh;
                    }
                }
            }

            dataGridView2.Columns["LichTrinh"].Visible      = false;
            dataGridView2.Columns["Nguoi"].Visible          = false;
            dataGridView2.Columns["MaNguoi"].Visible        = false;
            dataGridView2.Columns["MaLichTrinh"].Visible    = false;
            dataGridView2.Columns["MaLichTrinhTam"].Visible = false;
        }
コード例 #2
0
        public static List <LichTrinh> LoadAllLichTrinhs()
        {
            List <LichTrinh> lichTrinhs = new List <LichTrinh>();

            try
            {
                ATINChamCongEntities context = new ATINChamCongEntities();
                lichTrinhs = context.spGetAllLichTrinh().ToList();
                return(lichTrinhs);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return(null);
            }
        }
コード例 #3
0
        private void Set()
        {
            ATINChamCongEntities context = new ATINChamCongEntities();
            var       lstLichTrinh       = context.spGetAllLichTrinh().ToList();
            LichTrinh lichTrinhNuLL      = new LichTrinh {
                MaLichTrinh = null, TenLichTrinh = "Chưa Xếp"
            };

            lstLichTrinh.Add(lichTrinhNuLL);
            List <LichTrinh> lstLichTrinh2 = new List <LichTrinh>(lstLichTrinh);

            comboBox1.DataSource      = lstLichTrinh;
            comboBox2.DataSource      = lstLichTrinh2;
            comboBox1.DisplayMember   = "TenLichTrinh";
            comboBox2.DisplayMember   = "TenLichTrinh";
            comboBox1.ValueMember     = "MaLichTrinh";
            comboBox2.ValueMember     = "MaLichTrinh";
            dateEditFromDate.DateTime = DateTime.Now;
            dateEditToDate.DateTime   = DateTime.Now;
        }
コード例 #4
0
        //using Singleton to create only one Instance of form
        private PrepareEmployeeCalenda()
        {
            InitializeComponent();
            this.Dock = DockStyle.Fill;
            SetDoubleBuffer(dataGridView1, true);
            SetDoubleBuffer(dataGridView2, true);
            TreeView1Config();
            ATINChamCongEntities context = new ATINChamCongEntities();
            var       lstLichTrinh       = context.spGetAllLichTrinh().ToList();
            LichTrinh lichTrinhEmpty     = new LichTrinh {
                MaLichTrinh = null, TenLichTrinh = "Chưa Xếp", LoaiChuKy = null
            };

            lstLichTrinh.Add(lichTrinhEmpty);
            DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn();

            col.DataSource                           = lstLichTrinh;
            col.Name                                 = "col";
            col.DisplayMember                        = "TenLichTrinh";
            col.DataPropertyName                     = "MaLichTrinh";
            col.ValueMember                          = "MaLichTrinh";
            col.HeaderText                           = "Lịch trình";
            col.AutoSizeMode                         = DataGridViewAutoSizeColumnMode.DisplayedCells;
            col.DefaultCellStyle.NullValue           = lichTrinhEmpty.TenLichTrinh;
            col.DefaultCellStyle.DataSourceNullValue = lichTrinhEmpty.MaLichTrinh;
            dataGridView1.Columns.Add(col);

            DataGridViewCheckBoxColumn checkCol = new DataGridViewCheckBoxColumn();

            checkCol.Name                                 = "Checkbox";
            checkCol.DataPropertyName                     = "Checkbox";
            checkCol.HeaderText                           = "";
            checkCol.AutoSizeMode                         = DataGridViewAutoSizeColumnMode.None;
            checkCol.Width                                = 120;
            checkCol.DefaultCellStyle.NullValue           = false;
            checkCol.DefaultCellStyle.DataSourceNullValue = false;
            dataGridView1.Columns.Add(checkCol);

            Set();
        }