private void getInfo() { _KT_CTuGocRepo = new KT_CTuGocRepo(); int id = Utils.CIntDef(gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "ID"), 0); KT_CTuGoc obj = _KT_CTuGocRepo.GetById(id); if (obj != null) { txtLoai.Text = obj.MA_CTU; txtSo.Text = obj.SO_CTU; txtNgay.Text = ""; if (obj.NGAY_CTU != null) txtNgay.Text = obj.NGAY_CTU.Value.ToString("dd/MM/yyyy"); txtDiengiai.Text = obj.DIEN_GIAI; txtTenKH.Text = obj.TEN_KH; txtSoHD.Text = obj.HD_SO; txtNgayHD.Text = ""; if (obj.HD_NGAY != null) txtNgayHD.Text = obj.HD_NGAY.Value.ToString("dd/MM/yyyy"); txtSeriHD.Text = obj.HD_SR; //txtUsdTienHang.Text = string.Format("", o txtUsdChietkhau.Text = string.Format("{0:#,###}", obj.CHIET_KHAU_USD); txtUsdTienthue.Text = string.Format("{0:#,###}", obj.TIEN_THUE_USD); txtUsdTongtien.Text = string.Format("{0:#,###}", obj.TONG_TIEN_USD); txtVndTienhang.Text = string.Format("{0:#,###}", obj.TIEN_HANG); //txtVndChietkhau1.Text = string.Format("{0:#,###}", obj.CHIET_KHAU_VND); txtVndChietkhau2.Text = string.Format("{0:#,###}", obj.CHIET_KHAU_VND); //txtVndTienthue1.Text = string.Format("{0:#,###}", obj.TIEN_THUE_VND); txtVndTienthue2.Text = string.Format("{0:#,###}", obj.TIEN_THUE_VND); txtVndTongtien.Text = string.Format("{0:#,###}", obj.TONG_TIEN_VND); } }
private void Load_Data() { try { _KT_CTuGocRepo = new KT_CTuGocRepo(); gridData.DataSource = _KT_CTuGocRepo.GetAllByThangNam(Utils.CIntDef(fTerm._month, 0), Utils.CIntDef(fTerm._year, 0)); } catch (Exception) { } }
protected void cboLoaiCTu_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { 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), ""); #region move_focus TextBox[] arrTxt = { txtSeriHD }; ComboBox[] arrCbo = { cboMaTT, cboMaHD }; next_focus(arrTxt, arrCbo, 2); #endregion } }
private void btnSave_Click(object sender, EventArgs e) { if (_listCTuGoc != null && _listCTuGoc.Count > 0) { _KT_CTuGocRepo = new KT_CTuGocRepo(); _KT_CTuGocRepo.Create(_listCTuGoc); MessageBox.Show("Lưu thành công", "Thông báo"); EnableCtu(true); _listCTuGoc = new List<KT_CTuGoc>(); LoadGrid2(); LoadSTT(); } }
private void Save_Data(bool msg) { try { _KT_CTuGocRepo = new KT_CTuGocRepo(); int i = 0; foreach (int pos in _listUpdate) { int id = Utils.CIntDef(gridView1.GetRowCellValue(pos, "ID").ToString(), 0); KT_CTuGoc obj = _KT_CTuGocRepo.GetById(id); if (obj != null) { Get_Data(ref obj, pos); _KT_CTuGocRepo.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 gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { try { GridView view = sender as GridView; _KT_CTuGocRepo = new KT_CTuGocRepo(); //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_CTuGoc obj = new KT_CTuGoc(); Get_Data(ref obj, e.RowHandle); _KT_CTuGocRepo.Create(obj); } //Cũ thì update else { int id = Utils.CIntDef(gridView1.GetRowCellValue(e.RowHandle, "ID").ToString(), 0); KT_CTuGoc obj = _KT_CTuGocRepo.GetById(id); if (obj != null) { Get_Data(ref obj, e.RowHandle); _KT_CTuGocRepo.Update(obj); } } Load_Data(); } catch (Exception ex) { e.Valid = false; MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Remove_Data() { try { //if (_listUpdate.Count > 0) //{ // MessageBox.Show("Hãy thực hiện lưu trước khi xóa!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} Save_Data(false); _KT_CTuGocRepo = new KT_CTuGocRepo(); int Id = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID").ToString(), 0); _KT_CTuGocRepo.Remove(Id); //MessageBox.Show("Xóa dòng ID:" + Id + " thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); Load_Data(); } catch (Exception ex) { 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) { _KT_CTuGocRepo = new KT_CTuGocRepo(); KT_CTuGoc obj = new KT_CTuGoc(); Get_Data(ref obj, gridView1.FocusedRowHandle); _KT_CTuGocRepo.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); } }
private void Save_Tick() { try { _KT_CTuGocRepo = new KT_CTuGocRepo(); int _id = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID").ToString(), 0); KT_CTuGoc obj = _KT_CTuGocRepo.GetById(_id); if (obj != null) { obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DANH_DAU"), "").Trim() == "T" ? "" : "T"; _KT_CTuGocRepo.Update(obj); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnLuu_Click(object sender, EventArgs e) { try { _KT_CTuGocRepo = new KT_CTuGocRepo(); int id = Utils.CIntDef(gridView2.GetRowCellValue(gridView2.FocusedRowHandle, "ID"), 0); KT_CTuGoc obj = _KT_CTuGocRepo.GetById(id); if (obj != null) { obj.MA_CTU = txtLoai.Text; obj.SO_CTU = txtSo.Text; obj.NGAY_CTU = null; if(txtNgay.Text.Length >0) obj.NGAY_CTU = DateTime.ParseExact(txtNgay.Text, "d/M/yyyy", CultureInfo.InvariantCulture); obj.DIEN_GIAI = txtDiengiai.Text; obj.TEN_KH = txtTenKH.Text; obj.HD_SO = txtSoHD.Text; obj.HD_NGAY = null; if (txtNgayHD.Text.Length > 0) obj.HD_NGAY = DateTime.ParseExact(txtNgayHD.Text, "d/M/yyyy", CultureInfo.InvariantCulture); obj.HD_SR = txtSeriHD.Text; //txtUsdTienHang.Text = string.Format("", o obj.CHIET_KHAU_USD = Utils.CDblDef(txtUsdChietkhau.Text.Replace(",", "").Replace(".", ""), 0); obj.TIEN_THUE_USD = Utils.CDblDef(txtUsdTienthue.Text.Replace(",", "").Replace(".", ""), 0); obj.TONG_TIEN_USD = Utils.CDblDef(txtUsdTongtien.Text.Replace(",", "").Replace(".", ""), 0); obj.TIEN_HANG = Utils.CDblDef(txtVndTienhang.Text.Replace(",", "").Replace(".", ""), 0); //txtVndChietkhau1.Text = string.Format("{0:#,###}", obj.CHIET_KHAU_VND); obj.CHIET_KHAU_VND = Utils.CDblDef(txtVndChietkhau2.Text.Replace(",", "").Replace(".", ""), 0); //txtVndTienthue1.Text = string.Format("{0:#,###}", obj.TIEN_THUE_VND); obj.TIEN_THUE_VND = Utils.CDblDef(txtVndTienthue2.Text.Replace(",", "").Replace(".", ""), 0); obj.TONG_TIEN_VND = Utils.CDblDef(txtVndTongtien.Text.Replace(",", "").Replace(".", ""), 0); _KT_CTuGocRepo.Update(obj); MessageBox.Show("Cập nhật thành công!", "Thông báo"); int row = gridView2.FocusedRowHandle; _db = new dbVstoreAppDataContext(Const.builder.ConnectionString); var list = this._db.KT_CTuGocs.Where(u => u.NGAY_CTU.Value != null && u.NGAY_CTU.Value.Month == Utils.CIntDef(fTerm._month, 0) && u.NGAY_CTU.Value.Year == Utils.CIntDef(fTerm._year, 0) && (u.NGAY_CTU.Value.Day >= Utils.CIntDef(txtTungay.Text, 0) || Utils.CIntDef(txtTungay.Text, 0) == 0) && (u.NGAY_CTU.Value.Day <= Utils.CIntDef(txtDenngay.Text, 0) || Utils.CIntDef(txtDenngay.Text, 0) == 0) && (u.MA_CTU == Utils.CStrDef(cboLoaichungtu.SelectedValue, "") || Utils.CStrDef(cboLoaichungtu.SelectedValue, "") == "") && (u.SO_CTU == Utils.CStrDef(cboSochungtu.SelectedValue, "") || Utils.CStrDef(cboSochungtu.SelectedValue, "") == "")); gridData2.DataSource = list; gridView2.FocusedRowHandle = row; getInfo(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }