public decimal AreaAddWithIdentity(AreaInfo areainfo) { decimal decAreaId = 0; try { decAreaId = SpArea.AreaAddWithIdentity(areainfo); } catch (Exception ex) { MessageBox.Show("AR3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(decAreaId); }
/// <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) { MessageBox.Show("AR3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }