예제 #1
0
        /// <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);
                //}
            }
        }