コード例 #1
0
ファイル: frmArea.cs プロジェクト: hnjm/OneAccount
 /// <summary>
 /// area grid cell double click for update
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvArea_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             string strArea = dgvArea.CurrentRow.Cells["dgvtxtarea"].Value.ToString();
             if (strArea != "NA")
             {
                 AreaInfo infoArea = new AreaInfo();
                 AreaSP   spArea   = new AreaSP();
                 infoArea          = spArea.AreaFill(Convert.ToDecimal(dgvArea.CurrentRow.Cells[1].Value.ToString()));
                 txtAreaName.Text  = infoArea.AreaName;
                 txtNarration.Text = infoArea.Narration;
                 btnSave.Text      = "Update";
                 btnDelete.Enabled = true;
                 txtAreaName.Focus();
                 decAreaId = Convert.ToDecimal(dgvArea.CurrentRow.Cells[1].Value.ToString());
             }
             else
             {
                 Messages.WarningMessage("NA Area cannot update or delete");
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "AR16:" + ex.Message;
     }
 }
コード例 #2
0
ファイル: frmArea.cs プロジェクト: hnjm/OneAccount
 /// <summary>
 /// Function to fill area datagridview
 /// </summary>
 public void AreaGridfill()
 {
     try
     {
         DataTable dtbl   = new DataTable();
         AreaSP    spArea = new AreaSP();
         dtbl = spArea.AreaOnlyViewAll();
         dgvArea.DataSource = dtbl;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "AR1:" + ex.Message;
     }
 }
コード例 #3
0
 /// <summary>
 /// Function to fill Area combobox
 /// </summary>
 public void AreaForComboFill()
 {
     try
     {
         AreaSP    spArea = new AreaSP();
         DataTable dtbl   = spArea.AreaViewFOrCombofill();
         cmbArea.DataSource    = dtbl;
         cmbArea.DisplayMember = "areaName";
         cmbArea.ValueMember   = "areaId";
         cmbArea.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "SORP6:" + ex.Message;
     }
 }
コード例 #4
0
ファイル: frmArea.cs プロジェクト: hnjm/OneAccount
 /// <summary>
 /// delete function
 /// </summary>
 public void Delete()
 {
     try
     {
         if (Messages.DeleteConfirmation())
         {
             AreaSP spArea = new AreaSP();
             if (spArea.AreaDeleteReference(decAreaId) <= 0)
             {
                 Messages.ReferenceExistsMessage();
             }
             else
             {
                 Messages.DeletedMessage();
                 Clear();
             }
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "AR4:" + ex.Message;
     }
 }
コード例 #5
0
ファイル: frmArea.cs プロジェクト: hnjm/OneAccount
 /// <summary>
 /// Checking the invalid entries fro save or update
 /// </summary>
 public void SaveOrEdit()
 {
     try
     {
         if (txtAreaName.Text.Trim() == string.Empty)
         {
             Messages.InformationMessage("Enter area name");
             txtAreaName.Focus();
         }
         else
         {
             AreaInfo infoArea = new AreaInfo();
             AreaSP   spArea   = new AreaSP();
             infoArea.AreaName  = txtAreaName.Text.Trim();
             infoArea.Narration = txtNarration.Text.Trim();
             infoArea.Extra1    = string.Empty;
             infoArea.Extra2    = string.Empty;
             infoArea.AreaId    = decAreaId;
             if (btnSave.Text == "Save")
             {
                 if (Messages.SaveConfirmation())
                 {
                     if (spArea.AreaNameCheckExistence(txtAreaName.Text.Trim(), 0) == false)
                     {
                         decAreaId = spArea.AreaAddWithIdentity(infoArea);
                         //RouteNACreateUnderTheArea();
                         AreaGridfill();
                         Messages.SavedMessage();
                         Clear();
                         decIdForOtherForms = decAreaId;
                         if (frmRouteObj != null)
                         {
                             this.Close();
                         }
                         if (frmCustomerobj != null)
                         {
                             this.Close();
                         }
                         if (frmSupplierobj != null)
                         {
                             this.Close();
                         }
                     }
                     else
                     {
                         Messages.InformationMessage("Area name already exist");
                         txtAreaName.Focus();
                     }
                 }
             }
             else
             {
                 if (Messages.UpdateConfirmation())
                 {
                     if (spArea.AreaNameCheckExistence(txtAreaName.Text.Trim(), decAreaId) == false)
                     {
                         infoArea.AreaId = decAreaId;
                         if (spArea.AreaUpdate(infoArea))
                         {
                             AreaGridfill();
                             Messages.UpdatedMessage();
                             Clear();
                         }
                         //else if (infoArea.AreaId == 1)
                         //{
                         //    Messages.WarningMessage("Cannot Update or Delete");
                         //    Clear();
                         //    txtAreaName.Focus();
                         //}
                     }
                     else
                     {
                         Messages.InformationMessage("Area name already exist");
                         txtAreaName.Focus();
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "AR3:" + ex.Message;
     }
 }