/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { ModelNoBll BllModelNo = new ModelNoBll(); ModelNoInfo infoModelNo = new ModelNoInfo(); infoModelNo.ModelNo = txtModalNo.Text.Trim(); infoModelNo.Narration = txtNarration.Text.Trim(); infoModelNo.Extra1 = string.Empty; infoModelNo.Extra2 = string.Empty; if (BllModelNo.ModelCheckIfExist(txtModalNo.Text.Trim().ToString(), 0) == false) { decIdForOtherForms = BllModelNo.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 fill datagridview /// </summary> public void Gridfill() { try { List <DataTable> listModelNo = new List <DataTable>(); ModelNoBll BllModelNo = new ModelNoBll(); listModelNo = BllModelNo.ModelNoOnlyViewAll(); dgvModalNo.DataSource = listModelNo[0]; } catch (Exception ex) { MessageBox.Show("MN2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit /// </summary> public void EditFunction() { try { ModelNoBll BllModelNo = new ModelNoBll(); 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 (BllModelNo.ModelCheckIfExist(txtModalNo.Text.Trim(), decModelNo) == false) { if (BllModelNo.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 { BllModelNo.ModelNoEditParticularFeilds(infoModelNo); Messages.UpdatedMessage(); Clear(); } } catch (Exception ex) { MessageBox.Show("MN4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the ModelNo combobox /// </summary> public void ModelComboFill() { try { ModelNoBll BllModelNo = new ModelNoBll(); List <DataTable> listModelNo = new List <DataTable>(); listModelNo = BllModelNo.ModelNoViewAll(); DataRow dr = listModelNo[0].NewRow(); dr[1] = "All"; listModelNo[0].Rows.InsertAt(dr, 0); cmbModelNo.DataSource = listModelNo[0]; cmbModelNo.ValueMember = "modelNoId"; cmbModelNo.DisplayMember = "modelNo"; } catch (Exception ex) { MessageBox.Show("PSP4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill controls for update /// </summary> public void FillControls() { try { ModelNoInfo infoModelNo = new ModelNoInfo(); ModelNoBll BllModelNo = new ModelNoBll(); infoModelNo = BllModelNo.ModelNoWithNarrationView(Convert.ToDecimal(dgvModalNo.CurrentRow.Cells[1].Value.ToString())); txtModalNo.Text = infoModelNo.ModelNo; txtNarration.Text = infoModelNo.Narration; btnSave.Text = "Update"; btnDelete.Enabled = true; decModelNo = infoModelNo.ModelNoId; strModelNo = infoModelNo.ModelNo; } catch (Exception ex) { MessageBox.Show("MN8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to delete /// </summary> public void DeleteFunction() { try { ModelNoBll BllModelNo = new ModelNoBll(); if (BllModelNo.ModelNoCheckReferenceAndDelete(decModelNo) <= 0) { Messages.ReferenceExistsMessage(); } else { BllModelNo.ModelNoDelete(Convert.ToDecimal(dgvModalNo.CurrentRow.Cells[1].Value.ToString())); Clear(); Messages.DeletedMessage(); } } catch (Exception ex) { MessageBox.Show("MN6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }