/// <summary> /// Function to save and edit account group /// </summary> public void SaveOrEdit() { try { strAccountGroupName = btnSave.Text == "Save" ? string.Empty : strAccountGroupName; if (CheckExistanceOfGroupName() == false) { if (txtAccountGroupName.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter account group name"); txtAccountGroupName.Focus(); } else if (cmbGroupUnder.SelectedIndex == -1) { Messages.InformationMessage("Select under"); cmbGroupUnder.Focus(); } else if (cmbNature.SelectedIndex == -1) { Messages.InformationMessage("Select nature"); cmbNature.Focus(); } else { AccountGroupInfo infoAccountGroup = new AccountGroupInfo(); AccountGroupSP spAccountGroup = new AccountGroupSP(); infoAccountGroup.AccountGroupName = txtAccountGroupName.Text.Trim(); infoAccountGroup.GroupUnder = Convert.ToDecimal(cmbGroupUnder.SelectedValue.ToString()); infoAccountGroup.Nature = cmbNature.SelectedItem.ToString(); if (cmbAffectGrossProfit.SelectedIndex == -1) { infoAccountGroup.AffectGrossProfit = "No"; } else { infoAccountGroup.AffectGrossProfit = cmbAffectGrossProfit.SelectedItem.ToString(); } infoAccountGroup.IsDefault = false; infoAccountGroup.Narration = txtNarration.Text.Trim(); infoAccountGroup.Extra1 = string.Empty; infoAccountGroup.Extra2 = string.Empty; if (btnSave.Text == "Save") { if (Messages.SaveConfirmation()) { decAccountGroupId = spAccountGroup.AccountGroupAddWithIdentity(infoAccountGroup); Messages.SavedMessage(); decIdForOtherForms = decAccountGroupId; if (frmAccountLedgerobj != null) { this.Close(); } GridFill(); Clear(); } } else { if (isDefault == true) { Messages.InformationMessage("Can't update build in account group"); } else if (txtAccountGroupName.Text.Trim().ToLower() != cmbGroupUnder.Text.ToLower()) { if (Messages.UpdateConfirmation()) { infoAccountGroup.AccountGroupId = decAccountGroupIdForEdit; if (spAccountGroup.AccountGroupUpdate(infoAccountGroup)) { Messages.UpdatedMessage(); } GridFill(); Clear(); } } else { Messages.InformationMessage(" Can't save under same group"); } } } } else { Messages.InformationMessage(" Account group already exist"); txtAccountGroupName.Focus(); } } catch (Exception ex) { MessageBox.Show("AG8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }