/// <summary> /// Function for delete form /// </summary> public void Delete() { try { string str = MessageBox.Show("Are you sure to delete ?", "Print", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString(); if (str == "Yes") { FormSP spForm = new FormSP(); FieldSP spField = new FieldSP(); bool isOk = spForm.FormDelete(informId); if (isOk) { spField.FieldsDelete(informId); Clear(); FillGrid(); frmPrintDesigner.obj.FormFill(); MessageBox.Show("Deleted successfully", "Forms", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Reference exist in print design", "Forms", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { formMDI.infoError.ErrorString = "forms4" + ex.Message; } }
/// <summary> /// Function for save form details /// </summary> public void Save() { try { FormInfo infoForm = new FormInfo(); FormSP spForm = new FormSP(); FieldInfo infoField = new FieldInfo(); FieldSP spField = new FieldSP(); int inId = 0; infoForm.FormName = txtFormName.Text; if (informId == 0) { inId = spForm.FormAdd(infoForm); if (inId > -1) { infoField.FormId = inId; int inCount = dgvFields.Rows.Count - 1; for (int i = 0; i < inCount; i++) { infoField.FieldName = dgvFields.Rows[i].Cells["fieldName"].Value.ToString(); spField.FieldsAdd(infoField); } Clear(); MessageBox.Show("Saved successfully", "Forms", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Form name alredy exist", "Forms", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { inId = informId; infoForm.FormId = inId; bool isOk = spForm.FormEdit(infoForm); if (!isOk) { if (MessageBox.Show("Reference exist in print design, do you want to continue ?", "Forms", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { isOk = true; spForm.FormEditFull(infoForm); } } if (isOk) { infoField.FormId = inId; spField.FieldsDelete(inId); int inCount = dgvFields.Rows.Count - 1; for (int i = 0; i < inCount; i++) { infoField.FieldName = dgvFields.Rows[i].Cells["fieldName"].Value.ToString(); spField.FieldsAdd(infoField); } Clear(); MessageBox.Show("Updated successfully", "Forms", MessageBoxButtons.OK, MessageBoxIcon.Information); } } frmPrintDesigner.obj.FormFill(); FillGrid(); } catch (Exception ex) { formMDI.infoError.ErrorString = "forms3" + ex.Message; } }