private void Get_Data(KB_LCTT_TT obj, int position) { try { obj.SAP_XEP = Utils.CStrDef(gridView1.GetRowCellValue(position, "SAP_XEP"), ""); obj.CHI_TIEU = Utils.CStrDef(gridView1.GetRowCellValue(position, "CHI_TIEU"), ""); obj.TEN_CT1 = Utils.CStrDef(gridView1.GetRowCellValue(position, "TEN_CT1"), ""); obj.TEN_CT2 = Utils.CStrDef(gridView1.GetRowCellValue(position, "TEN_CT2"), ""); obj.MA_SO = Utils.CStrDef(gridView1.GetRowCellValue(position, "MA_SO"), ""); obj.SO_DU = Utils.CStrDef(gridView1.GetRowCellValue(position, "SO_DU"), ""); obj.TK_NO = Utils.CStrDef(gridView1.GetRowCellValue(position, "TK_NO"), ""); obj.TK_CO = Utils.CStrDef(gridView1.GetRowCellValue(position, "TK_CO"), ""); obj.TT_KT_VND = Utils.CDblDef(gridView1.GetRowCellValue(position, "TT_KT_VND"), 0); obj.TT_KN_VND = Utils.CDblDef(gridView1.GetRowCellValue(position, "TT_KN_VND"), 0); obj.TT_KT_USD = Utils.CDblDef(gridView1.GetRowCellValue(position, "TT_KT_USD"), 0); obj.TT_KN_USD = Utils.CDblDef(gridView1.GetRowCellValue(position, "TT_KN_USD"), 0); obj.NHAN_VOI = Utils.CDblDef(gridView1.GetRowCellValue(position, "NHAN_VOI"), 0); obj.THUYET_MINH = Utils.CStrDef(gridView1.GetRowCellValue(position, "THUYET_MINH"), ""); obj.CO_IN = Utils.CStrDef(gridView1.GetRowCellValue(position, "CO_IN"), ""); obj.TT_LK_VND = Utils.CDblDef(gridView1.GetRowCellValue(position, "TT_LK_VND"), 0); obj.TT_LK_USD = Utils.CDblDef(gridView1.GetRowCellValue(position, "TT_LK_USD"), 0); obj.TT_NT_USD = Utils.CDblDef(gridView1.GetRowCellValue(position, "TT_NT_USD"), 0); obj.TT_NT_VND = Utils.CDblDef(gridView1.GetRowCellValue(position, "TT_NT_VND"), 0); obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(position, "DANH_DAU"), ""); obj.TRANG_THAI = Utils.CIntDef(gridView1.GetRowCellValue(position, "TRANG_THAI"), 0); } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { try { GridView view = sender as GridView; _KBLCTT_TTRepo = new KBLCTT_TTRepo(); //Kiểm tra đây là dòng dữ liệu mới hay cũ, nếu là mới thì mình insert if (view.IsNewItemRow(e.RowHandle)) { //e.RowHandle trả về giá trị int là thứ tự của dòng hiện tại KB_LCTT_TT obj = new KB_LCTT_TT(); Get_Data(obj, e.RowHandle); _KBLCTT_TTRepo.Create(obj); } //Cũ thì update else { string id = Utils.CStrDef(gridView1.GetRowCellValue(e.RowHandle, "CHI_TIEU").ToString(), ""); KB_LCTT_TT obj = _KBLCTT_TTRepo.GetById(id); if (obj != null) { Get_Data(obj, e.RowHandle); _KBLCTT_TTRepo.Update(obj); } } Load_Data(); } catch (Exception ex) { e.Valid = false; MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Save_Duplicate() { try { if (MessageBox.Show("Bạn có muốn copy dòng này thành dòng mới?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _KBLCTT_TTRepo = new KBLCTT_TTRepo(); KB_LCTT_TT obj = new KB_LCTT_TT(); Get_Data(obj, gridView1.FocusedRowHandle); _KBLCTT_TTRepo.Create(obj); MessageBox.Show("Đã copy dòng này vào cuối bảng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
partial void DeleteKB_LCTT_TT(KB_LCTT_TT instance);
partial void UpdateKB_LCTT_TT(KB_LCTT_TT instance);
partial void InsertKB_LCTT_TT(KB_LCTT_TT instance);