/// <summary> /// Search aggregates role /// </summary> private void Search() { this.panelLabelNoResult.Visible = false; if (string.IsNullOrEmpty(this.txt_codice.Text) && string.IsNullOrEmpty(this.txt_descrizione.Text)) { string s = "<script language='javascript'>alert('Attenzione! Per poter effettuare la ricerca è necessario compilare i campi codice e/o descrizione');</script>"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "WarningSearch", s, false); } else { string typeAur = ddlAur.SelectedItem.Value; string code = txt_codice.Text; string description = txt_descrizione.Text; ListResultAur = ws.SearchAur(typeAur, code, description, ID_ADMINISTRATION).ToList(); if (ListResultAur != null && ListResultAur.Count > 0) { this.upPnlResult.Visible = true; GrdAssertionResult.DataSource = BuildObjectAggregatorRole(ListResultAur); GrdAssertionResult.DataBind(); this.GrdAssertionResult.SelectedIndex = Convert.ToInt32(this.grdAssertionResult_rowindex.Value); HighlightSelectedRow(GrdAssertionResult); upPnlResult.Update(); } else { GrdAssertionResult.DataSource = null; GrdAssertionResult.DataBind(); this.panelLabelNoResult.Visible = true; } } this.upPnlResult.Update(); }
protected void GrdAssertionResult_PageIndexChanging(object sender, GridViewPageEventArgs e) { this.GrdAssertionResult.PageIndex = e.NewPageIndex; this.grdAssertionResult_rowindex.Value = "0"; GrdAssertionResult.DataSource = BuildObjectAggregatorRole(ListResultAur); GrdAssertionResult.DataBind(); this.GrdAssertionResult.SelectedIndex = Convert.ToInt32(this.grdAssertionResult_rowindex.Value); HighlightSelectedRow(GrdAssertionResult); upPnlResult.Update(); }
/// <summary> /// Insert assertions /// </summary> private void InsertAssertion() { if (CheckValue()) // se supero i controlli sui valori immessi nel pannello asserzione, preparo l'oggetto asserzione da inserire { Assertion newAssertion = new Assertion(); newAssertion.ID_TYPE_EVENT = Convert.ToInt64(ddlTypeEvent.SelectedItem.Value); newAssertion.DESC_TYPE_EVENT = ddlTypeEvent.SelectedItem.Text; newAssertion.TYPE_AUR = ddlAur.SelectedItem.Value; if (newAssertion.TYPE_AUR.Equals(TYPE_AUR_ADMINISTRATION)) { newAssertion.ID_AUR = Convert.ToInt64(ID_ADMINISTRATION); newAssertion.DESC_AUR = CODE_ADMINISTRATION; } else { newAssertion.ID_AUR = Convert.ToInt64((GrdAssertionResult.SelectedRow.FindControl("lblSystemIdAggregator") as Label).Text); newAssertion.DESC_AUR = (GrdAssertionResult.SelectedRow.FindControl("lblCode") as Label).Text + "(" + (GrdAssertionResult.SelectedRow.FindControl("lblDescription") as Label).Text + ")"; } newAssertion.TYPE_NOTIFY = Convert.ToChar(rbTipologiaNotifica.SelectedItem.Value); newAssertion.IS_EXERCISE = cbInEsercizio.Checked; newAssertion.ID_AMM = Convert.ToInt64(ID_ADMINISTRATION); //chiamo il servizio di insert //0 - inserimento riuscito con successo //1 - l'asserzione è già presente //-1 - si è verificato un errore durante l'inserimento dell'asserzione. int valRet = ws.InsertAssertionEvent(newAssertion); if (valRet == 0) { //recupero le asserzioni dal backend Assertions = ws.GetListAssertion(ID_ADMINISTRATION).ToList(); //aggiorno la griglia delle asserzioni this.grid_rowindex.Value = "0"; BuildGrdAssertions(); MODE = "Modify"; BuildPanelAssertion(); GrdAssertionResult.DataSource = null; GrdAssertionResult.DataBind(); this.grdAssertionResult_rowindex.Value = "0"; pnlAssertion.Update(); UpdatePanelGridView.Update(); } else if (valRet == -1) { string s = "<script language='javascript'>alert('Si è verificato un errore durante l\\'inserimento dell\\'asserzione.');</script>"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "errorInsertAssertion", s, false); } else if (valRet == 1) { string s = "<script language='javascript'>alert('l\\'asserzione è già presente.');</script>"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "duplicateAssertion", s, false); } } }
/// <summary> /// Modify assertion /// </summary> private void ModifyAssertion() { Assertion assertion = new Assertion(); if (CheckValue()) { assertion.SYSTEM_ID = Convert.ToInt64((this.GrdAsserzioni.Rows[this.GrdAsserzioni.SelectedIndex].FindControl("lblSystemId") as Label).Text); assertion.ID_TYPE_EVENT = Convert.ToInt64(ddlTypeEvent.SelectedItem.Value); assertion.DESC_TYPE_EVENT = ddlTypeEvent.SelectedItem.Text; assertion.ID_AMM = Convert.ToInt64(ID_ADMINISTRATION); if (GrdAssertionResult.Rows == null || GrdAssertionResult.Rows.Count < 1) { if (ddlAur.SelectedItem.Value.Equals(TYPE_AUR_ADMINISTRATION)) { assertion.DESC_AUR = CODE_ADMINISTRATION; assertion.ID_AUR = Convert.ToInt64(ID_ADMINISTRATION); } else { assertion.DESC_AUR = (this.GrdAsserzioni.Rows[this.GrdAsserzioni.SelectedIndex].FindControl("lblAur") as Label).Text; assertion.ID_AUR = (from a in Assertions where a.SYSTEM_ID.ToString().Equals(assertion.SYSTEM_ID.ToString()) select a.ID_AUR).FirstOrDefault(); } } else { assertion.DESC_AUR = (this.GrdAssertionResult.Rows[this.GrdAssertionResult.SelectedIndex].FindControl("lblCode") as Label).Text + "(" + (this.GrdAssertionResult.Rows[this.GrdAssertionResult.SelectedIndex].FindControl("lblDescription") as Label).Text + ")"; assertion.ID_AUR = Convert.ToInt64((this.GrdAssertionResult.Rows[this.GrdAssertionResult.SelectedIndex].FindControl("lblSystemIdAggregator") as Label).Text); } assertion.IS_EXERCISE = cbInEsercizio.Checked; assertion.TYPE_AUR = ddlAur.SelectedValue; assertion.TYPE_NOTIFY = Convert.ToChar(rbTipologiaNotifica.SelectedValue); bool isPresent = (from a in Assertions where (a.ID_TYPE_EVENT.Equals(assertion.ID_TYPE_EVENT) && a.ID_AUR.Equals(assertion.ID_AUR) && a.TYPE_AUR.Equals(assertion.TYPE_AUR) && a.ID_AMM.Equals(assertion.ID_AMM) && !a.SYSTEM_ID.ToString().Equals(assertion.SYSTEM_ID.ToString())) select a).Count() > 0; if (isPresent) { string s = "<script language='javascript'>alert('L\\'asserzione è già presente.');</script>"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "duplicateAssertion", s, false); return; } //service modify int res = ws.UpdateAssertionEvent(assertion); if (res == 0) { //recupero le asserzioni dal backend Assertions = ws.GetListAssertion(ID_ADMINISTRATION).ToList(); //aggiorno la griglia delle asserzioni BuildGrdAssertions(); MODE = "Modify"; BuildPanelAssertion(); GrdAssertionResult.DataSource = null; GrdAssertionResult.DataBind(); this.grdAssertionResult_rowindex.Value = "0"; pnlAssertion.Update(); UpdatePanelGridView.Update(); } else if (res == -1) { string s = "<script language='javascript'>alert('Si è verificato un problema durante la modifica dell\\'asserzione selezionata');</script>"; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "errorUpdateAssertion", s, false); } //else if (res == 1) //{ // string s = "<script language='javascript'>alert('l\\'asserzione è già presente.');</script>"; // ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "duplicateAssertion", s, false); //} } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { //leggo l'id dell'amministrazione corrente string[] amministrazione = ((string)Session["AMMDATASET"]).Split('@'); string codiceAmministrazione = amministrazione[0]; string idAmm = ws.getIdAmmByCod(codiceAmministrazione); CODE_ADMINISTRATION = codiceAmministrazione; ID_ADMINISTRATION = idAmm; //popolo la drop down list con i tipi evento configurabili BuildDdlTypeConfigurableEvents(); //Popolo la griglia delle asserzioni Assertions = ws.GetListAssertion(ID_ADMINISTRATION).ToList(); //Popolo la griglia delle asserzioni Initialize(); BuildGrdAssertions(); //Popolo il pannello dell'asserzione if (this.GrdAsserzioni != null && this.GrdAsserzioni.Rows.Count > 0) { MODE = "Modify"; } else { MODE = "Hidden"; } BuildPanelAssertion(); } else { if (this.Request.Form["__EVENTTARGET"] != null && this.Request.Form["__EVENTTARGET"].Equals(UPDATE_PANEL_GRID_VIEW)) { if (this.Request.Form["__EVENTARGUMENT"] != null && (this.Request.Form["__EVENTARGUMENT"].Equals(REMOVE_SELECTED_ASSERTION))) { RemoveAssertion(); return; } if (this.Request.Form["__EVENTARGUMENT"] != null && (this.Request.Form["__EVENTARGUMENT"].Equals(SELECTED_ASSERTION_IN_GRID_VIEW))) { //Popolo la griglia delle asserzioni BuildGrdAssertions(); if (GrdAssertionResult.Rows != null && GrdAssertionResult.Rows.Count > 0) { GrdAssertionResult.DataSource = null; GrdAssertionResult.DataBind(); this.grdAssertionResult_rowindex.Value = "0"; this.txt_codice.Text = string.Empty; this.txt_descrizione.Text = string.Empty; } //Popolo il pannello dell'asserzione if (!MODE.Equals("New")) { BuildPanelAssertion(); } this.UpdatePanelGridView.Update(); this.UpPnlCodiceDescrizione.Update(); return; } } if (this.Request.Form["__EVENTTARGET"] != null && this.Request.Form["__EVENTTARGET"].Equals(UPDATE_PANEL_RESULT)) { if (this.Request.Form["__EVENTARGUMENT"] != null && (this.Request.Form["__EVENTARGUMENT"].Equals(BTN_CERCA))) { Search(); return; } if (this.Request.Form["__EVENTARGUMENT"] != null && (this.Request.Form["__EVENTARGUMENT"].Equals(UPDATE_GRD_AGGREGATES))) { GrdAssertionResult.DataSource = BuildObjectAggregatorRole(ListResultAur); GrdAssertionResult.DataBind(); this.GrdAssertionResult.SelectedIndex = Convert.ToInt32(this.grdAssertionResult_rowindex.Value); HighlightSelectedRow(GrdAssertionResult); upPnlResult.Update(); return; } } if (this.Request.Form["__EVENTTARGET"] != null && this.Request.Form["__EVENTTARGET"].Equals(UPDATE_PANEL_CODICE_DESCRIZIONE)) { if (GrdAssertionResult.Rows != null && GrdAssertionResult.Rows.Count > 0) { GrdAssertionResult.DataSource = null; GrdAssertionResult.DataBind(); txt_codice.Text = string.Empty; txt_descrizione.Text = string.Empty; this.grdAssertionResult_rowindex.Value = "0"; } if (!ddlAur.SelectedItem.Value.Equals(TYPE_AUR_ADMINISTRATION)) { pnlCodiceDescrizione.Attributes["style"] = "display:block"; txt_codice.Text = string.Empty; txt_descrizione.Text = string.Empty; //pnlCodiceDescrizione.Visible = true; } else { pnlCodiceDescrizione.Attributes["style"] = "display:none"; txt_codice.Text = string.Empty; txt_descrizione.Text = string.Empty; //pnlCodiceDescrizione.Visible = false; } return; } /* * //Popolo la griglia delle asserzioni * BuildGrdAssertions(); * this.UpdatePanelGridView.Update(); * //Popolo il pannello dell'asserzione * if(!MODE.Equals("New")) * BuildPanelAssertion();*/ } }