コード例 #1
0
ファイル: Object.aspx.cs プロジェクト: sebbalex/PITre
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "function", "<script>reallowOp();</script>", false);
            try
            {
                string errMsg = string.Empty;

                DocsPaWR.Oggetto  oggetto  = new DocsPaWR.Oggetto();
                DocsPaWR.Registro registro = new DocsPaWR.Registro();

                #region Validators
                //check on insert of the object
                if (string.IsNullOrEmpty(this.TxtDescObject.Text.Trim()))
                {
                    errMsg = "ErrorObjectNoObject";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectNoObject", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true);
                    return;
                }

                //check over the length of the object (up to 2000 characters.)
                if (this.TxtDescObject.Text.Length > Convert.ToInt32(this.MaxLenghtObject))
                {
                    errMsg = "ErrorObjectLength";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectLength", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true);
                    return;
                }
                #endregion

                //replace single quotes
                oggetto.descrizione = this.TxtDescObject.Text.Trim();// .Replace("'", "''"); Escape viene fatto dai WS


                //Adding the object code if there
                if (!string.IsNullOrEmpty(this.TxtCodObject.Text.Trim()))
                {
                    oggetto.codOggetto = this.TxtCodObject.Text.Trim(); // .Replace("'", "''"); Escape viene fatto dai WS
                }
                else
                {
                    oggetto.codOggetto = "";
                }

                if (this.DdlRegRf.SelectedItem.Value.Equals(""))
                {
                    if (TypeDoc.Equals("p"))                                      // protocol
                    {
                        registro        = RegistryManager.GetRegistryInSession(); //get protocol registry
                        registro.codice = this.DdlRegRf.SelectedItem.Text;
                    }
                    else if (TypeDoc.Equals("psempl"))
                    {
                        // simplified protocol
                        registro = new Registro();
                    }
                    else
                    {
                        registro = null;
                        errMsg   = "ErrorRegisterNotSelected";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorRegisterNotSelected", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true);
                        return;
                    }
                }
                else
                {
                    registro.systemId = this.DdlRegRf.SelectedValue.Split('_').First();
                    registro.codice   = this.DdlRegRf.SelectedItem.Text;
                }

                /*
                 * if (!string.IsNullOrEmpty(this.TxtCodObject.Text.Trim()))
                 * {
                 *  if ((from obj in ObjectstListAll where obj.codOggetto.Equals(this.TxtCodObject.Text.Trim()) && obj.codRegistro.Equals(registro.codice) select obj).Count() > 0)
                 *  {
                 *      errMsg = "ErrorObjectCodePresent";
                 *      ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectCodePresent", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true);
                 *      return;
                 *  }
                 * }
                 * if ((from obj in ObjectstListAll where obj.descrizione.Equals(this.TxtDescObject.Text.Trim()) && obj.codRegistro.Equals(registro.codice) select obj).Count() > 0)
                 * {
                 *  errMsg = "ErrorObjectVoicePresent";
                 *  ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectVoicePresent", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true);
                 *  return;
                 * }
                 */
                oggetto = ObjectManager.AddObject(this, oggetto, registro, ref errMsg);

                if (oggetto != null)
                {
                    oggetto.codRegistro = registro.codice;
                    List <Oggetto> listObj = new List <Oggetto>();
                    listObj.Add(oggetto);

                    /*
                     * List<Oggetto> l = ObjectstListAll.ToList<Oggetto>();
                     * l.Add(oggetto);
                     * ObjectstListAll = l.ToArray<Oggetto>();
                     * */
                    this.GridSearchObject.DataSource = listObj;
                    this.GridSearchObject.DataBind();
                    this.GridSearchObject.SelectedIndex = 0;
                    this.GridSearchObject.Visible       = true;
                    this.BtnOk.Enabled           = true;
                    this.ObjectBtnDelete.Enabled = true;
                    this.UpPnlButtons.Update();
                    this.UpdPnlGridSearch.Update();
                }
                else
                {
                    if (string.IsNullOrEmpty(this.TxtCodObject.Text.Trim()))
                    {
                        errMsg = "ErrorObjectCodeObjectPresent";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectCodeObjectPresent", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true);
                    }
                    else
                    {
                        errMsg = "ErrorObjectPresent";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectPresent", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true);
                    }
                }
            }
            catch (System.Exception ex)
            {
                UIManager.AdministrationManager.DiagnosticError(ex);
            }
        }
コード例 #2
0
ファイル: Object.aspx.cs プロジェクト: sebbalex/PITre
        /// <summary>
        /// Load registry and RF
        /// </summary>
        private void LoadRegistryRF()
        {
            // if protocol or simplified protocol
            if (TypeDoc.Equals("p") || TypeDoc.Equals("psempl"))
            {
                DocsPaWR.Registro reg = null;
                if (TypeDoc.Equals("p"))
                {
                    //get protocol registry
                    reg = RegistryManager.GetRegistryInSession();
                }
                else
                {
                    //simplified protocol
                }

                this.DdlRegRf.Items.Add(new ListItem()
                {
                    Text = reg.codRegistro, Value = string.Empty, Selected = true
                });
                //I take the RF associated with the registry protocol
                Registro[] listRF = RegistryManager.GetListRegistriesAndRF(UIManager.RoleManager.GetRoleInSession().systemId, "1", reg.systemId);
                if (listRF != null && listRF.Length > 0)
                {
                    /*I value della combo dei registri sono formati da terne separate dal carattere "_":
                     * nella prima posizione viene specificata la systemId dell'RF
                     * nella seconda posizione 0 per gli RF abilitati, 1 per gli RF non abilitati
                     * nella terza posizione viene specificato l'IdAooCollegata (solo per gli RF)
                     */
                    ListItem[] listItemRF = (from rf in listRF
                                             select new ListItem()
                    {
                        Text = rf.codRegistro,
                        Value = rf.systemId + "_" + rf.rfDisabled + "_" + rf.idAOOCollegata
                    }).ToArray();

                    if (listItemRF != null && listItemRF.Length > 0)
                    {
                        foreach (ListItem li in listItemRF)
                        {
                            li.Attributes.Add("style", "margin-left:10px;");
                        }
                        this.DdlRegRf.Items.AddRange(listItemRF);
                    }
                    Stack <Registro> stackRegistries = new Stack <Registro>(listRF);
                    stackRegistries.Push(reg);
                    this.ObjectRegistryList = stackRegistries.ToArray();
                }
                else
                {
                    this.ObjectRegistryList = new Registro[] { reg };
                }
            }
            else // case gray documents and search
            {
                this.DdlRegRf.Items.Add(new ListItem()
                {
                    Text = "TUTTI", Value = string.Empty, Selected = true
                });
                Registro[] ListRegistriesAndRF = RegistryManager.GetListRegistriesAndRF(UIManager.RoleManager.GetRoleInSession().systemId, string.Empty, string.Empty);
                var        PairRegRF           = (from reg in ListRegistriesAndRF
                                                  where reg.chaRF.Equals("0")
                                                  select(new
                {
                    IdReg = reg.systemId,
                    CodReg = reg.codRegistro,
                    ListItemRF =
                        (from rf in ListRegistriesAndRF
                         where rf.idAOOCollegata == reg.systemId
                         select new ListItem()
                    {
                        Text = rf.codRegistro, Value = rf.systemId + "_" + rf.rfDisabled + "_" + rf.idAOOCollegata
                    }).ToArray()
                }));
                if (PairRegRF != null)
                {
                    foreach (var RegAssRF in PairRegRF)
                    {
                        this.DdlRegRf.Items.Add(new ListItem()
                        {
                            Text = RegAssRF.CodReg, Value = RegAssRF.IdReg
                        });
                        if ((RegAssRF.ListItemRF as ListItem[]) != null && (RegAssRF.ListItemRF as ListItem[]).Length > 0)
                        {
                            foreach (ListItem li in (RegAssRF.ListItemRF as ListItem[]))
                            {
                                li.Attributes.Add("style", "margin-left:10px;");
                            }
                            this.DdlRegRf.Items.AddRange(RegAssRF.ListItemRF as ListItem[]);
                        }
                    }
                }
                this.ObjectRegistryList = ListRegistriesAndRF;
            }
        }