private void dgvFamilyList_CellContentClick(object sender, DataGridViewCellEventArgs e) { int columnIndex = e.ColumnIndex; int rowIndex = e.RowIndex; //AddCode if (rowIndex == -1) { return; } //AddCode if (this.dgvFamilyList.Columns[columnIndex] == this.dgvFamilyList.Columns[_delColumnName]) { var dialogResult = MessageBox.Show("确定要删除吗?", SystemInfo.ReminderStr, MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.OK) { var peopleFamilyID = (int)dgvFamilyList.Rows[rowIndex].Cells["PeopleFamilyID"].Value; var result = new PeopleFamilyBLL().DeletePeopleFamilyByID(peopleFamilyID); if (result.Code > 0) { MessageBox.Show(result.Message, SystemInfo.ErrorReminderStr, MessageBoxButtons.OK); } BindGridList(); } } else if (this.dgvFamilyList.Columns[columnIndex] == this.dgvFamilyList.Columns[_editColumName]) { var peopleFamilyID = (int)dgvFamilyList.Rows[rowIndex].Cells["PeopleFamilyID"].Value; var familyInfoForm = new FamilyInfoForm(true, peopleFamilyID, null); familyInfoForm.callbackEvent += delegate { BindGridList(); }; familyInfoForm.ShowDialog(); } }
private void BindControlValue() { var result = new PeopleFamilyBLL().GetPeopleFamilyByID(this._currentPeopleFamilyID.Value); if (result.Code > 0) { MessageBox.Show(result.Message, SystemInfo.ReminderStr, MessageBoxButtons.OK); this.Dispose(); } var peopleFamily = result.Data; this.txtRelation.Text = peopleFamily.Relation; this.txtFamilyPeopleName.Text = peopleFamily.FamilyPeopleName; this.txtWorkUnit.Text = peopleFamily.WorkUnit; this.txtTitle.Text = peopleFamily.Title; this.txtPhoneNum.Text = peopleFamily.PhoneNum; this.txtAddress.Text = peopleFamily.Address; }
private void BindGridList() { var peopleFamilyList = new PeopleFamilyBLL().GetPeopleFamilyList(_currentPeopleID).Data; this.dgvFamilyList.AutoGenerateColumns = false; this.dgvFamilyList.DataSource = peopleFamilyList; }
private void btnSave_Click(object sender, EventArgs e) { var peopleFamily = new PeopleFamily(); peopleFamily.Relation = this.txtRelation.Text; peopleFamily.FamilyPeopleName = this.txtFamilyPeopleName.Text; peopleFamily.WorkUnit = this.txtWorkUnit.Text; peopleFamily.Title = this.txtTitle.Text; peopleFamily.PhoneNum = this.txtPhoneNum.Text; peopleFamily.Address = this.txtAddress.Text; var bll = new PeopleFamilyBLL(); if (this._isEdit) { if (this._currentPeopleFamilyID.HasValue) { peopleFamily.PeopleFamilyID = this._currentPeopleFamilyID.Value; var result = bll.UpdatePeopleFamily(peopleFamily); MessageHelper.ShowSaveDbResultMessage(result); if (result.Code == 0) { this.Dispose(); } } } else { if (this._peopleID.HasValue) { peopleFamily.PeopleID = this._peopleID.Value; var result = bll.InsertPeopleFamily(peopleFamily); MessageHelper.ShowSaveDbResultMessage(result); if (result.Code == 0) { this.Dispose(); } } } if (callbackEvent != null) { callbackEvent.Invoke(); } }