/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { ModelNoSP spModelNo = new ModelNoSP(); ModelNoInfo infoModelNo = new ModelNoInfo(); infoModelNo.ModelNo = txtModalNo.Text.Trim(); infoModelNo.Narration = txtNarration.Text.Trim(); infoModelNo.Extra1 = string.Empty; infoModelNo.Extra2 = string.Empty; if (spModelNo.ModelCheckIfExist(txtModalNo.Text.Trim().ToString(), 0) == false) { decIdForOtherForms = spModelNo.ModelNoAddWithDifferentModelNo(infoModelNo); if (decIdForOtherForms > 0) { Messages.SavedMessage(); Clear(); } } else { Messages.InformationMessage("Model number already exist"); txtModalNo.Focus(); } } catch (Exception ex) { MessageBox.Show("MN3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit /// </summary> public void EditFunction() { try { ModelNoSP spModelNo = new ModelNoSP(); ModelNoInfo infoModelNo = new ModelNoInfo(); infoModelNo.ModelNo = txtModalNo.Text.Trim(); infoModelNo.Narration = txtNarration.Text.Trim(); infoModelNo.Extra1 = string.Empty; infoModelNo.Extra2 = string.Empty; infoModelNo.ModelNoId = Convert.ToDecimal(dgvModalNo.CurrentRow.Cells[1].Value.ToString()); if (txtModalNo.Text != strModelNo) { if (spModelNo.ModelCheckIfExist(txtModalNo.Text.Trim(), decModelNo) == false) { if (spModelNo.ModelNoEditParticularFeilds(infoModelNo)) { Messages.UpdatedMessage(); Clear(); } else if (infoModelNo.ModelNoId == 1) { Messages.InformationMessage("Cannot update"); Clear(); txtModalNo.Focus(); } } else { Messages.InformationMessage("Model number already exist"); txtModalNo.Focus(); } } else { spModelNo.ModelNoEditParticularFeilds(infoModelNo); Messages.UpdatedMessage(); Clear(); } } catch (Exception ex) { MessageBox.Show("MN4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }