コード例 #1
0
 /// <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;
     }
 }
コード例 #2
0
 /// <summary>
 /// Function for fill the grid
 /// </summary>
 public void FillGrid()
 {
     try
     {
         FormSP    spForm = new FormSP();
         DataTable dtbl   = new DataTable();
         dtbl = spForm.FormViewAll();
         dgvForms.DataSource = dtbl;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "forms2" + ex.Message;
     }
 }
コード例 #3
0
 /// <summary>
 /// On DataGridView dgvForms CellClick
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvForms_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (dgvForms.Rows.Count > 0)
         {
             informId = int.Parse(dgvForms.CurrentRow.Cells["formId"].Value.ToString());
             FormSP   spForm   = new FormSP();
             FormInfo infoForm = new FormInfo();
             FieldSP  spField  = new FieldSP();
             infoForm             = spForm.FormView(informId);
             txtFormName.Text     = infoForm.FormName;
             dgvFields.DataSource = spField.FieldsViewAll(informId);
             btnDelete.Enabled    = true;
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "forms7" + ex.Message;
     }
 }
コード例 #4
0
 /// <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;
     }
 }