public UCFormAddRoom() { InitializeComponent(); BUS = new PhonghocBUS(); if (Global.ActiveID) { Model.Models.phonghoc o = BUS.getdata().Find(x => x.maphong.Equals((string)Global.ID)); txtmaphong.Text = o.maphong; txttenphong.Text = o.tenphong; spdientich.Value = Convert.ToDecimal(o.dien_tich); spsiso.Value = Convert.ToDecimal(o.siso); pictureanh.Image = Images.DecodeImage(o.images); } }
protected override void ONCREATE() { CahocBUS ca = new CahocBUS(); PhonghocBUS phong = new PhonghocBUS(); var dic = new System.Collections.Generic.Dictionary<string, Nullable<System.TimeSpan>[]>(); tt = new TrangthaiphongBUS(); txtstmaphong.Properties.Items.AddRange(phong.getdataextract()); ClassRoomBUS.CahocBUS BUS = new ClassRoomBUS.CahocBUS(); dic.Add("", new Nullable<System.TimeSpan>[] { new TimeSpan(), new TimeSpan() }); ca.getdata().ForEach(i => { txtstmaca.Properties.Items.Add(i.maca); dic.Add(i.maca, new Nullable<System.TimeSpan>[] { System.TimeSpan.Parse(i.thoigianbatdau.ToString()), System.TimeSpan.Parse(i.thoigianketthuc.ToString()) }); }); txtstmaca.SelectedIndexChanged += (o, e) => { try { var d = dic[(string)txtstmaca.SelectedItem]; ststarttime.EditValue = new DateTime(d[0].Value.Ticks); stendtime.EditValue = new DateTime(d[1].Value.Ticks); } catch(Exception ex) { } }; gridControl1.DataSource = tt.getdata(); gridView1.RowClick += (o, e) => { var row = ((DevExpress.XtraGrid.Views.Grid.GridView)o); if (e.RowHandle != -1) { var column = row.Columns; txtstmaphong.SelectedItem = row.GetRowCellValue(e.RowHandle, column["maphong"]); txtstmaca.SelectedItem = row.GetRowCellValue(e.RowHandle, column["maca"]); stday.EditValue = row.GetRowCellValue(e.RowHandle, column["thoigianbatdau"]); ststarttime.EditValue = row.GetRowCellValue(e.RowHandle, column["thoigianbatdau"]); stendtime.EditValue = row.GetRowCellValue(e.RowHandle, column["thoigianketthuc"]); oldobj = new trangthaiphong{maphong = txtstmaphong.Text, maca = txtstmaca.Text, hientrang = txtsttrangthai.Text, thoigianbatdau = ststarttime.Time, thoigianketthuc = stendtime.Time, }; } }; this.UPClick += UCStateStandart_UPClick; this.DELClick += UCStateStandart_DELClick; this.ADDClick += UCStateStandart_ADDClick; }