private void Save_Data(bool msg) { try { _KTDTPNRepo = new KTDTPNRepo(); int i = 0; foreach (int pos in _listUpdate) { int id = Utils.CIntDef(gridView1.GetRowCellValue(pos, "ID"), 0); KT_DTPN obj = _KTDTPNRepo.GetById(id); if (obj != null) { obj.MA_DTPN = Utils.CStrDef(gridView1.GetRowCellValue(pos, "MA_DTPN"), ""); obj.TEN_DTPN = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TEN_DTPN"), ""); obj.DIA_CHI = Utils.CStrDef(gridView1.GetRowCellValue(pos, "DIA_CHI"), ""); obj.DIA_CHI_GH = Utils.CStrDef(gridView1.GetRowCellValue(pos, "DIA_CHI_GH"), ""); obj.MA_SO_THUE = Utils.CStrDef(gridView1.GetRowCellValue(pos, "MA_SO_THUE"), ""); obj.LIEN_HE = Utils.CStrDef(gridView1.GetRowCellValue(pos, "LIEN_HE"), ""); obj.DIEN_THOAI = Utils.CStrDef(gridView1.GetRowCellValue(pos, "DIEN_THOAI"), ""); obj.TK_NH = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TK_NH"), ""); obj.TEN_TKNH = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TEN_TKNH"), ""); obj.MA_TT = Utils.CStrDef(gridView1.GetRowCellValue(pos, "MA_TT"), ""); obj.TEN_TT = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TEN_TT"), ""); obj.MA_NHOM = Utils.CStrDef(gridView1.GetRowCellValue(pos, "MA_NHOM"), ""); obj.TEN_NHOM = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TEN_NHOM"), ""); obj.CK_PT = Utils.CDblDef(gridView1.GetRowCellValue(pos, "CK_PT"), 0); obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(pos, "DANH_DAU"), ""); obj.TRANG_THAI = Utils.CIntDef(gridView1.GetRowCellValue(pos, "TRANG_THAI"), 0); _KTDTPNRepo.Update(obj); i++; } } _listUpdate = new List<int>(); //if (i > 0 && msg) //{ // MessageBox.Show("Lưu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //} } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cboDTPNCo_SelectedIndexChanged(object sender, EventArgs e) { _KTDTPNRepo = new KTDTPNRepo(); var item = _KTDTPNRepo.GetById(Utils.CIntDef(cboDTPNCo.SelectedValue, 0)); if (item != null) txtDTPNCo.Text = item.TEN_DTPN; }
private void cboManhanvienban_SelectedIndexChanged(object sender, EventArgs e) { if (cboManhanvienban.SelectedIndex > -1 && tek > 2) { _KTDTPNRepo = new KTDTPNRepo(); var item = _KTDTPNRepo.GetById(Utils.CIntDef(cboManhanvienban.SelectedValue, 0)); if (item != null) txtTennhanvienban.Text = item.TEN_DTPN; } }
private void cboNguoigiaodich_SelectedIndexChanged(object sender, EventArgs e) { if (cboNguoigiaodich.SelectedIndex > -1 && tek > 2) { _KTDTPNRepo = new KTDTPNRepo(); var item = _KTDTPNRepo.GetById(Utils.CIntDef(cboNguoigiaodich.SelectedValue, 0)); if (item != null) { txtTennguoigiaodich.Text = item.TEN_DTPN; txtDiachiNGD.Text = item.DIA_CHI; } } }
//private void cboLoaiCTu_SelectedIndexChanged(object sender, EventArgs e) //{ // //tek++; // //if (cboLoaiCTu.SelectedIndex > -1 && tek > 2) // //{ // // EnableCtr(cboLoaiCTu.Text); // // _KT_CTuGocRepo = new KT_CTuGocRepo(); // // gridControl1.DataSource = _KT_CTuGocRepo.GetByMaCT(Utils.CStrDef(cboLoaiCTu.SelectedValue, ""), Utils.CIntDef(fTerm._month, 0), Utils.CIntDef(fTerm._year, 0), ""); // //} //} //private void cboTKNo_SelectedIndexChanged(object sender, EventArgs e) //{ // //if (cboTKNo.SelectedIndex > -1 && tek > 2) // //{ // // _KTTKRepo = new KTTKRepo(); // // var item = _KTTKRepo.GetById(Utils.CIntDef(cboTKNo.SelectedValue, 0)); // // if (item != null) // // txtTKNo.Text = item.TEN_TK; // //} //} //private void cboDTPNNo_SelectedIndexChanged(object sender, EventArgs e) //{ // //if (cboDTPNNo.SelectedIndex > -1 && tek > 2) // //{ // // _KTDTPNRepo = new KTDTPNRepo(); // // var item = _KTDTPNRepo.GetById(Utils.CIntDef(cboDTPNNo.SelectedValue, 0)); // // if (item != null) // // txtDTPNNo.Text = item.TEN_DTPN; // //} //} //private void cboYTCPNo_SelectedIndexChanged(object sender, EventArgs e) //{ // //if (cboYTCPNo.SelectedIndex > -1 && tek > 2) // //{ // // _KTYTCPRepo = new KTYTCPRepo(); // // var item = _KTYTCPRepo.GetById(Utils.CIntDef(cboYTCPNo.SelectedValue, 0)); // // if (item != null) // // txtYTCPNo.Text = item.TEN_YTCP_V; // //} //} //private void cboVTHHNo_SelectedIndexChanged(object sender, EventArgs e) //{ // //if (cboVTHHNo.SelectedIndex > -1 && tek > 2) // //{ // // _KTDMHHRepo = new KTDMHHRepo(); // // var item = _KTDMHHRepo.GetById(Utils.CIntDef(cboVTHHNo.SelectedValue, 0)); // // if (item != null) // // txtVTHHNo.Text = item.TEN_DM; // //} //} //private void cboTKCo_SelectedIndexChanged(object sender, EventArgs e) //{ // //if (cboTKCo.SelectedIndex > -1 && tek > 2) // //{ // // _KTTKRepo = new KTTKRepo(); // // var item = _KTTKRepo.GetById(Utils.CIntDef(cboTKCo.SelectedValue, 0)); // // if (item != null) // // txtTKCo.Text = item.TEN_TK; // //} //} //private void cboDTPNCo_SelectedIndexChanged(object sender, EventArgs e) //{ // //if (cboDTPNCo.SelectedIndex > -1 && tek > 2) // //{ // // _KTDTPNRepo = new KTDTPNRepo(); // // var item = _KTDTPNRepo.GetById(Utils.CIntDef(cboDTPNCo.SelectedValue, 0)); // // if (item != null) // // txtDTPNCo.Text = item.TEN_DTPN; // //} //} //private void cboYTCPCo_SelectedIndexChanged(object sender, EventArgs e) //{ // //if (cboYTCPCo.SelectedIndex > -1 && tek > 2) // //{ // // _KTYTCPRepo = new KTYTCPRepo(); // // var item = _KTYTCPRepo.GetById(Utils.CIntDef(cboYTCPCo.SelectedValue, 0)); // // if (item != null) // // txtYTCPCo.Text = item.TEN_YTCP_V; // //} //} //private void cboVTHHCo_SelectedIndexChanged(object sender, EventArgs e) //{ // //if (cboVTHHCo.SelectedIndex > -1 && tek > 2) // //{ // // _KTDMHHRepo = new KTDMHHRepo(); // // var item = _KTDMHHRepo.GetById(Utils.CIntDef(cboVTHHCo.SelectedValue, 0)); // // if (item != null) // // txtVTHHCo.Text = item.TEN_DM; // //} //} private void cboMakhachhang_SelectedIndexChanged(object sender, EventArgs e) { if (cboVTHHCo.SelectedIndex > -1 && tek > 2) { _KTDTPNRepo = new KTDTPNRepo(); var item = _KTDTPNRepo.GetById(Utils.CIntDef(cboMakhachhang.SelectedValue, 0)); if (item != null) { txtTenkhachhang.Text = item.TEN_DTPN; txtMasothue.Text = item.MA_SO_THUE; txtDiachi.Text = item.DIA_CHI; } } }
private void cboDTPNNo_KeyDown(object sender, KeyEventArgs e) { _KTDTPNRepo = new KTDTPNRepo(); var item = _KTDTPNRepo.GetById(Utils.CIntDef(cboDTPNNo.SelectedValue, 0)); if (item != null) txtDTPNNo.Text = item.TEN_DTPN; }
private void Save_Tick() { try { _KTDTPNRepo = new KTDTPNRepo(); int _id = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID").ToString(), 0); KT_DTPN obj = _KTDTPNRepo.GetById(_id); if (obj != null) { obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DANH_DAU"), "").Trim() == "T" ? "" : "T"; _KTDTPNRepo.Update(obj); } } 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; _KTDTPNRepo = new KTDTPNRepo(); //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 KT_DTPN obj = new KT_DTPN(); obj.MA_DTPN = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_DTPN"), ""); obj.TEN_DTPN = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_DTPN"), ""); obj.DIA_CHI = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DIA_CHI"), ""); obj.DIA_CHI_GH = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DIA_CHI_GH"), ""); obj.MA_SO_THUE = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_SO_THUE"), ""); obj.LIEN_HE = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "LIEN_HE"), ""); obj.DIEN_THOAI = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DIEN_THOAI"), ""); obj.TK_NH = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TK_NH"), ""); obj.TEN_TKNH = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_TKNH"), ""); obj.MA_TT = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_TT"), ""); obj.TEN_TT = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_TT"), ""); obj.MA_NHOM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_NHOM"), ""); obj.TEN_NHOM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_NHOM"), ""); obj.CK_PT = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "CK_PT"), 0); obj.DANH_DAU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DANH_DAU"), ""); obj.TRANG_THAI = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "TRANG_THAI"), 0); _KTDTPNRepo.Create(obj); } //Cũ thì update else { int id = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "ID"), 0); KT_DTPN obj = _KTDTPNRepo.GetById(id); if (obj != null) { obj.MA_DTPN = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_DTPN"), ""); obj.TEN_DTPN = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_DTPN"), ""); obj.DIA_CHI = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DIA_CHI"), ""); obj.DIA_CHI_GH = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DIA_CHI_GH"), ""); obj.MA_SO_THUE = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_SO_THUE"), ""); obj.LIEN_HE = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "LIEN_HE"), ""); obj.DIEN_THOAI = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DIEN_THOAI"), ""); obj.TK_NH = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TK_NH"), ""); obj.TEN_TKNH = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_TKNH"), ""); obj.MA_TT = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_TT"), ""); obj.TEN_TT = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_TT"), ""); obj.MA_NHOM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_NHOM"), ""); obj.TEN_NHOM = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_NHOM"), ""); obj.CK_PT = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "CK_PT"), 0); obj.DANH_DAU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DANH_DAU"), ""); obj.TRANG_THAI = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "TRANG_THAI"), 0); _KTDTPNRepo.Update(obj); } } Load_Data(); } catch (Exception ex) { e.Valid = false; MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }