/// <summary> /// Function to save /// </summary> public void SaveFunction() { try { SiteInfo infoSite = new SiteInfo(); SiteSP spSite = new SiteSP(); infoSite.SiteName = txtSiteName.Text.Trim(); infoSite.Address = txtAddress.Text.Trim(); infoSite.managed = chkManaged.Checked; infoSite.dflt = chkDflt.Checked; if (spSite.SiteCheckIfExist(txtSiteName.Text.Trim(), 0) == false) { decIdForOtherForms = spSite.SiteAddWithoutSameName(infoSite); if (decIdForOtherForms > 0) { Messages.SavedMessage(); Clear(); } } else { Messages.InformationMessage("Site name already exist"); txtSiteName.Focus(); } } catch (Exception ex) { formMDI.infoError.ErrorString = "G4:" + ex.Message; } }
/// <summary> /// Function to fill datagridview /// </summary> public void Gridfill() { try { DataTable tblSites = new DataTable(); SiteSP spSites = new SiteSP(); tblSites = spSites.SiteOnlyViewAll(); dgvSites.DataSource = tblSites; } catch (Exception ex) { formMDI.infoError.ErrorString = "G7:" + ex.Message; } }
/// <summary> /// Function to fill controls for update /// </summary> public void FillControls() { try { SiteInfo infoSites = new SiteInfo(); SiteSP spSites = new SiteSP(); infoSites = spSites.SiteWithNarrationView(Convert.ToDecimal(dgvSites.CurrentRow.Cells[1].Value.ToString())); txtSiteName.Text = infoSites.SiteName; txtAddress.Text = infoSites.Address; btnSave.Text = "Update"; btnDelete.Enabled = true; decSiteId = infoSites.SiteId; strSiteName = infoSites.SiteName; chkManaged.Checked = infoSites.managed; chkDflt.Checked = infoSites.dflt; } catch (Exception ex) { formMDI.infoError.ErrorString = "G11:" + ex.Message; } }
/// <summary> /// Function to Edit /// </summary> public void EditFunction() { try { SiteInfo infoSites = new SiteInfo(); SiteSP spSites = new SiteSP(); infoSites.SiteName = txtSiteName.Text.Trim(); infoSites.Address = txtAddress.Text.Trim(); infoSites.managed = chkManaged.Checked; infoSites.dflt = chkDflt.Checked; infoSites.SiteId = Convert.ToDecimal(dgvSites.CurrentRow.Cells["dgvtxtSiteId"].Value.ToString()); if (txtSiteName.Text != strSiteName) { if (spSites.SiteCheckIfExist(txtSiteName.Text.Trim(), infoSites.SiteId) == false) { if (spSites.SiteEditParticularField(infoSites)) { Messages.UpdatedMessage(); Clear(); } } else { Messages.InformationMessage("Site name already exist"); txtSiteName.Focus(); } } else { spSites.SiteEditParticularField(infoSites); Messages.UpdatedMessage(); Clear(); } } catch (Exception ex) { formMDI.infoError.ErrorString = "G5:" + ex.Message; } }
/// <summary> /// Function to delete /// </summary> public void DeleteFunction() { try { SiteSP spSite = new SiteSP(); if (spSite.SiteCheckReferenceAndDelete(decSiteId) <= 0) { Messages.ReferenceExistsMessage(); } else { // spGodown.GodownDelete(Convert.ToDecimal(dgvGodown.CurrentRow.Cells[1].Value.ToString())); //spGodown.GodownDelete(Convert.ToDecimal(dgvGodown.CurrentRow.Cells["dgvtxtGodownId"].Value.ToString())); Clear(); btnSave.Text = "Save"; Messages.DeletedMessage(); } } catch (Exception ex) { formMDI.infoError.ErrorString = "G8:" + ex.Message; } }