private void btnDelete_Click(object sender, System.EventArgs e) { if (grdAddress.CurrentRowIndex <= -1) { return; } int Id = int.Parse(grdAddress[grdAddress.CurrentRowIndex, 0].ToString()); AddressData st = AddressDataManager.GetAddressData(Id); if (st == null) { return; } if (MessageBox.Show("آیا برای حذف مطمئن هستید ؟", "AddressBook", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK) { st.Status = eStatus.Deleted; AddressDataManager.UpdateAddressData(st);//SourcePress,www.SourcePress.gigfa.com } else { return; } LoadAddressGrid();//SourcePress,www.SourcePress.gigfa.com txtSearchByName.Focus(); SetEditState(false); ClearFields(); LoadCurrentItem(); }
private void LoadAddressGrid() { string criteria = "Name like '%" + txtSearchByName.Text + "%' AND status <> " + (int)eStatus.Deleted; addressTable = AddressDataManager.GetAddressess(criteria); grdAddress.DataSource = addressTable; }
private void LoadAddresses()//SourcePress,www.SourcePress.gigfa.com { if (grdAddress.CurrentRowIndex <= -1) { return; } int Id = int.Parse(grdAddress[grdAddress.CurrentRowIndex, 0].ToString()); AddressData frm = AddressDataManager.GetAddressData(Id); if (frm == null) //SourcePress,www.SourcePress.gigfa.com { MessageBox.Show("اطلاعات قابل دریافت نمی باشد " + Id, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } txtName.Text = frm.Name; txtAddress.Text = frm.Address; txtPhone.Text = frm.Phone; txtFatherName.Text = frm.Father; dtDOB.Value = frm.DOB; txtQualification.Text = frm.Quali; txtNationality.Text = frm.Nationality; txtDesignation.Text = frm.Desig; txtMailId.Text = frm.Email; txtOtherDetails.Text = frm.Remarks; }
private void LoadCurrentItem() { if (grdAddress.CurrentRowIndex == -1) // Is there any row selected now? { btnEdit.Enabled = false; btnDelete.Enabled = false; return;//SourcePress,www.SourcePress.gigfa.com } int Id = int.Parse(grdAddress[grdAddress.CurrentRowIndex, 0].ToString()); AddressData addressdata = AddressDataManager.GetAddressData(Id); if (addressdata == null) { MessageBox.Show("اطلاعات قابل دریافت نمی باشد", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } txtName.Text = addressdata.Name; txtAddress.Text = addressdata.Address; txtPhone.Text = addressdata.Phone; txtFatherName.Text = addressdata.Father; dtDOB.Value = addressdata.DOB; txtQualification.Text = addressdata.Quali; txtNationality.Text = addressdata.Nationality; txtDesignation.Text = addressdata.Desig; txtMailId.Text = addressdata.Email; txtOtherDetails.Text = addressdata.Remarks; }
private void LoadAddresses() { if (grdAddress.CurrentRowIndex <= -1) { return; } int Id = int.Parse(grdAddress[grdAddress.CurrentRowIndex, 0].ToString()); AddressData frm = AddressDataManager.GetAddressData(Id); if (frm == null) { MessageBox.Show("Couldn't retrieve information for the id " + Id, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } txtName.Text = frm.Name; txtAddress.Text = frm.Address; txtPhone.Text = frm.Phone; txtFatherName.Text = frm.Father; dtDOB.Value = frm.DOB; txtQualification.Text = frm.Quali; txtNationality.Text = frm.Nationality; txtDesignation.Text = frm.Desig; txtMailId.Text = frm.Email; txtOtherDetails.Text = frm.Remarks; }
private void LoadCurrentItem() { if (grdAddress.CurrentRowIndex == -1) // Is there any row selected now? { btnEdit.Enabled = false; btnDelete.Enabled = false; return; } // The first column of the grid contains the id field. Since the width of the // field is set to zero, the column is not visible in the grid. But we // can still access the value in it. // Retrieve the first column from the selected row. int Id = int.Parse(grdAddress[grdAddress.CurrentRowIndex, 0].ToString()); AddressData addressdata = AddressDataManager.GetAddressData(Id); if (addressdata == null) { MessageBox.Show("Couldn't retrieve the object for the selected row.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } txtName.Text = addressdata.Name; txtAddress.Text = addressdata.Address; txtPhone.Text = addressdata.Phone; txtFatherName.Text = addressdata.Father; dtDOB.Value = addressdata.DOB; txtQualification.Text = addressdata.Quali; txtNationality.Text = addressdata.Nationality; txtDesignation.Text = addressdata.Desig; txtMailId.Text = addressdata.Email; txtOtherDetails.Text = addressdata.Remarks; }
private void btnSave_Click(object sender, System.EventArgs e) { if (txtName.Text.Trim() == String.Empty) { MessageBox.Show("Please enter the name.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtName.Focus(); return; } AddressData addressdata; if (pageAction == "ADD") { addressdata = new AddressData(); int id = IdManager.GetNextID("AddressData", "RecId"); addressdata.RecId = id; } else { // We are editing an existing student. int id = int.Parse(grdAddress[grdAddress.CurrentRowIndex, 0].ToString()); addressdata = AddressDataManager.GetAddressData(id); } addressdata.Name = txtName.Text; addressdata.Address = txtAddress.Text; addressdata.Phone = txtPhone.Text; addressdata.Father = txtFatherName.Text; addressdata.DOB = dtDOB.Value; addressdata.Quali = txtQualification.Text; addressdata.Nationality = txtNationality.Text; addressdata.Desig = txtDesignation.Text; addressdata.Email = txtMailId.Text; addressdata.Remarks = txtOtherDetails.Text; if (pageAction == "ADD") { int id = IdManager.GetNextID("AddressData", "RecId"); addressdata.RecId = id; AddressDataManager.CreateAddressData(addressdata); } else { AddressDataManager.UpdateAddressData(addressdata); } LoadAddressGrid(); MessageBox.Show("Saved successfully.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); // Enable / Disable appropriate buttons. SetEditState(false); }
private void btnSave_Click(object sender, System.EventArgs e) { if (txtName.Text.Trim() == String.Empty) { MessageBox.Show("لطفا نام و نام خانوادگی را وارد نمایید", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtName.Focus(); return; } AddressData addressdata; if (pageAction == "ADD") { addressdata = new AddressData(); int id = IdManager.GetNextID("AddressData", "RecId"); addressdata.RecId = id; } else {//SourcePress,www.SourcePress.gigfa.com int id = int.Parse(grdAddress[grdAddress.CurrentRowIndex, 0].ToString()); addressdata = AddressDataManager.GetAddressData(id); } //SourcePress,www.SourcePress.gigfa.com addressdata.Name = txtName.Text; addressdata.Address = txtAddress.Text; addressdata.Phone = txtPhone.Text; addressdata.Father = txtFatherName.Text; addressdata.DOB = dtDOB.Value; addressdata.Quali = txtQualification.Text; addressdata.Nationality = txtNationality.Text; addressdata.Desig = txtDesignation.Text; addressdata.Email = txtMailId.Text; addressdata.Remarks = txtOtherDetails.Text; if (pageAction == "ADD") { int id = IdManager.GetNextID("AddressData", "RecId"); addressdata.RecId = id; AddressDataManager.CreateAddressData(addressdata); } else { AddressDataManager.UpdateAddressData(addressdata); } LoadAddressGrid(); MessageBox.Show("تغییرات با موفقیت ذخیره گردید", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); SetEditState(false); //SourcePress,www.SourcePress.gigfa.com }
private void btnDelete_Click(object sender, System.EventArgs e) { if (grdAddress.CurrentRowIndex <= -1) { return; } int Id = int.Parse(grdAddress[grdAddress.CurrentRowIndex, 0].ToString()); AddressData st = AddressDataManager.GetAddressData(Id); if (st == null) { return; } if (MessageBox.Show("Are you sure to delete the selected item ?", "AddressBook", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK) { st.Status = eStatus.Deleted; AddressDataManager.UpdateAddressData(st); } else { return; } //MessageBox.Show("Deleted Successfully", " AddressBook", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadAddressGrid(); txtSearchByName.Focus(); SetEditState(false); ClearFields(); LoadCurrentItem(); }