private void submit_Click(object sender, EventArgs e) { Models.HoatDong x = new Models.HoatDong(); if (!check()) { MessageBox.Show("Bạn chưa nhập hết dữ liệu!"); return; } x.tenhd = this.tenhd.Text.Trim(); x.ngaybd = this.start.Value; x.ngaykt = this.end.Value; x.kinhphi = Convert.ToInt32(this.kinhphi.Text.Trim()); x.mans = Convert.ToInt32(this.idNganSach.Text.Trim()); if (this.isEdit) { x.mahd = ((Models.HoatDong) this.data.CurrentRow.DataBoundItem).mahd; if (!x.update()) { MessageBox.Show("Mã ngân sách không tồn tại!"); return; } } else { if (!x.insert()) { MessageBox.Show("Mã ngân sách không tồn tại!"); return; } } this.cancel_Click(sender, e); this.LoadData(); }
static public List <Models.HoatDong> get() { List <Models.HoatDong> list = new List <Models.HoatDong>(); DataTable data = Models.HoatDong.get(); foreach (DataRow item in data.Rows) { Models.HoatDong row = new Models.HoatDong(item); list.Add(row); } return(list); }
private void delete_Click(object sender, EventArgs e) { DialogResult confirm = MessageBox.Show("Bạn muốn xóa hoạt động này?", "Xác nhận?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (confirm == DialogResult.Yes) { Models.HoatDong x = new Models.HoatDong(); x.mahd = ((Models.HoatDong) this.data.CurrentRow.DataBoundItem).mahd; x.delete(); this.cancel_Click(sender, e); this.LoadData(); } }
private void data_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { DataGridViewRow row = data.CurrentRow; if (!row.IsNewRow) { Models.HoatDong x = (Models.HoatDong) this.data.CurrentRow.DataBoundItem; this.isEdit = true; this.submit.Text = "Sửa"; this.tenhd.Text = x.tenhd; this.start.Value = x.ngaybd; this.idNganSach.Text = x.mans.ToString(); this.kinhphi.Text = x.kinhphi.ToString(); this.end.Value = x.ngaykt; } }
private void province_SelectedIndexChanged(object sender, EventArgs e) { string tentinh = (this.province.SelectedItem as Models.TinhThanh).tentinh; CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[this.data.DataSource]; currencyManager1.SuspendBinding(); foreach (DataGridViewRow item in this.data.Rows) { Models.HoatDong i = (item.DataBoundItem as Models.HoatDong); if (i.tentinh != tentinh) { item.Visible = false; } else { item.Visible = true; } if (tentinh == "Tất cả") { item.Visible = true; } } currencyManager1.ResumeBinding(); }