private void SelectCellAction(int index, int column, bool isMmouse) { dataGridView.Rows[index].Selected = true; if (!isMmouse) { dataGridView[0, index].Value = !Convert.ToBoolean(dataGridView.Rows[index].Cells[0].Value); } else { if (column == 0) { dataGridView[0, index].Value = !Convert.ToBoolean(dataGridView.Rows[index].Cells[0].Value); } } List <DataGridViewRow> selectedRows = (from row in dataGridView.Rows.Cast <DataGridViewRow>() where Convert.ToBoolean(row.Cells["CB"].Value) select row).ToList(); bntLuaChon.Enabled = (dataGridView.CurrentRow != null); bntXoa.Enabled = selectedRows.Count > 0; currentModel = (CongViecModel)dataGridView.CurrentSelected(currentModelList); if (currentModel != null) { txtMaCongViec.Text = currentModel.MaCV; txtCongViec.Text = currentModel.TenCV; } bntLuu.Enabled = true; bntTaoMoi.Enabled = true; }
/// <summary> /// To the entity. /// </summary> /// <param name="model">The model.</param> /// <param name="destination">The destination.</param> /// <returns>CongViec.</returns> public static CongViec ToEntity(this CongViecModel model, CongViec destination) { return(model.MapTo(destination)); }
/// <summary> /// To the entity. /// </summary> /// <param name="model">The model.</param> /// <returns>CongViec.</returns> public static CongViec ToEntity(this CongViecModel model) { return(model.MapTo <CongViecModel, CongViec>()); }
/// <summary> /// Selects the cell action. /// </summary> /// <param name="index">The index.</param> /// <param name="column"></param> /// <param name="isMmouse"></param> private void bntLuaChon_Click(object sender, EventArgs e) { currentModel = (CongViecModel)dataGridView.CurrentSelected(currentModelList); controller.Select(currentModel); }
private void bntLuu_Click(object sender, EventArgs e) { if (txtMaCongViec.Text == "") { MessageBox.Show("Mã công việc không được để rỗng"); return; } if (txtCongViec.Text == "") { MessageBox.Show("Tên công việc không được để rỗng"); return; } currentModel = (CongViecModel)dataGridView.CurrentSelected(currentModelList); if (currentModel != null) { var cm = currentModelList.Where(c => c.MaCV == txtMaCongViec.Text && c.ID != currentModel.ID); if (cm.Any()) { MessageBox.Show("Mã công việc đã tồn tại trong một bản ghi khác"); return; } var ct = currentModelList.Where(c => c.TenCV == txtCongViec.Text && c.ID != currentModel.ID); if (ct.Any()) { MessageBox.Show("Tên công việc đã tồn tại trong một bản ghi khác"); return; } currentModel.MaCV = txtMaCongViec.Text; currentModel.TenCV = txtCongViec.Text; controller.Update(currentModel); //re-update UI dataGridView.UpdateView("MaCongViec", currentModel.MaCV); dataGridView.UpdateView("TenCongViec", currentModel.TenCV); txtMaCongViec.Focus(); txtMaCongViec.SelectAll(); bntTaoMoi.Enabled = true; bntLuu.Enabled = true; } else { var cm = currentModelList.Where(c => c.MaCV == txtMaCongViec.Text); if (cm.Any()) { MessageBox.Show("Mã công việc đã tồn tại"); return; } var ct = currentModelList.Where(c => c.TenCV == txtCongViec.Text); if (ct.Any()) { MessageBox.Show("Tên công việc đã tồn tại"); return; } currentModel = new CongViecModel { MaCV = txtMaCongViec.Text, TenCV = txtCongViec.Text, }; controller.Insert(currentModel); txtMaCongViec.Focus(); txtMaCongViec.SelectAll(); //txtTenCongViec.Text = ""; controller.ReviewGrid(); bntTaoMoi.Enabled = true; bntLuu.Enabled = true; } }