private void gvTamUng_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                if (_GridView.FocusedRowHandle < 0)
                {
                    return;
                }
                VnsGiaoDich tmp = (VnsGiaoDich)_GridView.GetRow(_GridView.FocusedRowHandle);
                switch (e.Column.Name)
                {
                case "colKhoanChiId":
                    VnsDmKhoanChi tmpkc = (VnsDmKhoanChi)grlKhoanChi.GetRowByKeyValue(tmp.KhoanChiId);
                    if (tmpkc == null)
                    {
                        return;
                    }
                    tmp.ObjDmKhoanChi = tmpkc;
                    tmp.DienGiai      = tmpkc.TenKhoanChi;
                    break;

                case "colLoaiKhoanId":
                    tmp.ObjVnsMaLoaiKhoan = (VnsMaLoaiKhoan)grlLoaiKhoan.GetRowByKeyValue(tmp.LoaiKhoanId);
                    break;
                }
                _GridControl.RefreshDataSource();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void DeleteRow()
        {
            if (_GridView.FocusedRowHandle < 0)
            {
                return;
            }

            VnsGiaoDich gd = (VnsGiaoDich)_GridView.GetRow(_GridView.FocusedRowHandle);

            if (lstDelGiaoDich == null)
            {
                lstDelGiaoDich = new List <VnsGiaoDich>();
            }
            lstDelGiaoDich.Add(gd);
            _GridView.DeleteSelectedRows();
            _GridView.RefreshData();
        }
 private int SetFocusAfterAdd(GridView _GridView, DateTime beforeAdd)
 {
     for (int i = 0; i < _GridView.RowCount - 1; i++)
     {
         if (!_GridView.IsValidRowHandle(i))
         {
             continue;
         }
         VnsGiaoDich tmp = (VnsGiaoDich)_GridView.GetRow(i);
         if (tmp != null)
         {
             if (tmp.GioThemMoi >= beforeAdd)
             {
                 return(i);
             }
         }
     }
     return(0);
 }
        private void AddRow()
        {
            DateTime beforeAdd = DateTime.Now;

            System.Threading.Thread.Sleep(1);
            if (lstGiaoDich == null)
            {
                lstGiaoDich = new List <VnsGiaoDich>();
            }

            VnsGiaoDich tmp = new VnsGiaoDich();

            if (_GridView.FocusedRowHandle >= 0)
            {
                tmp = (VnsGiaoDich)_GridView.GetRow(_GridView.FocusedRowHandle);
            }

            if (tmp == null)
            {
                lstGiaoDich.Add(new VnsGiaoDich());
            }
            else
            {
                VnsGiaoDich tmpAddRow = new VnsGiaoDich();
                tmpAddRow.KhoanChiId     = tmp.KhoanChiId;
                tmpAddRow.ObjDmKhoanChi  = tmp.ObjDmKhoanChi;
                tmpAddRow.DienGiai       = tmp.DienGiai;
                tmpAddRow.NoiDungCapPhat = txtNoiDung.Text;
                lstGiaoDich.Add(tmpAddRow);
            }

            //_GridView.s
            //_GridControl.DataSource = lstGiaoDich;
            _GridView.RefreshData();

            SetFocusAfterAdd(_GridView, beforeAdd);
        }