protected void TxtCodeObject_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "function", "reallowOp();", true); try { List <DocsPaWR.Registro> registries = new List <Registro>(); registries = UIManager.RegistryManager.GetListRegistriesAndRF(UIManager.RoleManager.GetRoleInSession().systemId, "1", string.Empty).ToList <DocsPaWR.Registro>(); registries.Add(UIManager.RegistryManager.GetRegistryInSession()); List <string> aL = new List <string>(); if (registries != null) { for (int i = 0; i < registries.Count; i++) { aL.Add(registries[i].systemId); } } DocsPaWR.Oggetto[] listaObj = null; // E' inutile finire nel backend se la casella di testo è vuota (a parte il fatto che // la funzione, in questo caso, restituisce tutto l'oggettario) if (!string.IsNullOrEmpty(this.TxtCodeObject.Text.Trim())) { //In questo momento tralascio la descrizione oggetto che metto come stringa vuota listaObj = DocumentManager.getListaOggettiByCod(aL.ToArray <string>(), string.Empty, this.TxtCodeObject.Text); } else { listaObj = new DocsPaWR.Oggetto[] { new DocsPaWR.Oggetto() { descrizione = String.Empty, codOggetto = String.Empty } }; } if (listaObj != null && listaObj.Length > 0) { this.TxtObject.Text = listaObj[0].descrizione; this.TxtCodeObject.Text = listaObj[0].codOggetto; } else { this.TxtObject.Text = string.Empty; this.TxtCodeObject.Text = string.Empty; } this.UpdPnlObject.Update(); ScriptManager.RegisterStartupScript(this, this.GetType(), "focus", "$('#" + this.CreateNewDocumentBtnSave.ClientID + "').focus();", true); } catch (System.Exception ex) { UIManager.AdministrationManager.DiagnosticError(ex); return; } }
protected void btnDelete_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "function", "<script>reallowOp();</script>", false); DocsPaWR.Oggetto oggetto = new DocsPaWR.Oggetto(); DocsPaWR.Registro registro = new DocsPaWR.Registro(); DocsPaWR.Registro registroDoc = new DocsPaWR.Registro(); string msg = string.Empty; bool result; if (GridSearchObject.SelectedIndex == -1) { msg = "ErrorObjectSelRecDel"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectSelRecDel", "if (parent.fra_main) " + "{parent.fra_main.ajaxDialogModal('" + msg + "', 'warning', 'ATTENZIONE');} " + "else {parent.ajaxDialogModal('" + msg + "', 'warning', 'ATTENZIONE');}", true); return; } int selRow = GridSearchObject.SelectedRow.RowIndex; oggetto.daAggiornare = true; oggetto.systemId = (GridSearchObject.Rows[selRow].Cells[(int)oggettario.systemid].FindControl("systemid") as Label).Text; oggetto.descrizione = (GridSearchObject.Rows[selRow].Cells[(int)oggettario.description].FindControl("lblDescObject") as Label).Text; if (!string.IsNullOrEmpty((GridSearchObject.Rows[selRow].Cells[(int)oggettario.codobject].FindControl("lblCodObject") as Label).Text)) { oggetto.codOggetto = (GridSearchObject.Rows[selRow].Cells[(int)oggettario.codobject].FindControl("lblCodObject") as Label).Text; } result = ObjectManager.DeleteObject(this, oggetto); if (result) { this.ObjectstList = (from listObj in this.ObjectstList where (!string.IsNullOrEmpty(oggetto.systemId) && (!listObj.systemId.Equals(oggetto.systemId))) select listObj).ToArray(); //this.ObjectstListAll = (from listObj in this.ObjectstListAll where (!string.IsNullOrEmpty(oggetto.systemId) && (!listObj.systemId.Equals(oggetto.systemId))) // select listObj).ToArray(); this.GridSearchObject.SelectedIndex = -1; this.GridSearchObject.PageIndex = 0; this.BtnOk.Enabled = false; this.ObjectBtnDelete.Enabled = false; this.TxtCodObject.Text = string.Empty; this.TxtDescObject.Text = string.Empty; this.GridSearchObject.DataSource = this.ObjectstList; this.GridSearchObject.DataBind(); this.UpdPnlCodeObject.Update(); this.UpdPnlGridSearch.Update(); this.UpPnlButtons.Update(); } else { msg = "ErrorObjectRemove"; // if (parent.fra_main) {parent.fra_main.ajaxDialogModal();} else {top.ajaxDialogModal();} ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectRemove", "if (parent.fra_main) " + "{parent.fra_main.ajaxDialogModal('" + msg + "', 'warning', 'ATTENZIONE');} " + "else {parent.ajaxDialogModal('" + msg + "', 'warning', 'ATTENZIONE');}", true); } }
//Valorizzo la descrizione oggetto in base al codice se esiste! protected void txt_cod_oggetto_TextChanged(object sender, EventArgs e) { DocsPAWA.DocsPaWR.Registro[] listaRF; if (CodOggPostBack) { //Recupero la scheda corrente DocsPaWR.SchedaDocumento schedaDoc = DocumentManager.getDocumentoInLavorazione(this.Page); if (schedaDoc == null) { //Valorizzazione della schedaDoc nel caso di protocollazione semplice ProtocollazioneIngresso.Protocollo.ProtocolloMng protoMng = new ProtocollazioneIngresso.Protocollo.ProtocolloMng(this.Page); schedaDoc = protoMng.GetDocumentoCorrente(); } ////Valorizzo il registro corrente string[] listaReg = { "" }; try { //recupero la lista di registri per passarli allo user control oggetto ai fini della ricerca if (wnd == "proto") { //registro in sessione listaReg = UserManager.getListaIdRegistri(this.Page); } else { //se vengo dal protocollo Semplificato if (wnd == "protoSempl") { ProtocollazioneIngresso.Registro.RegistroMng regMng = new ProtocollazioneIngresso.Registro.RegistroMng(this.Page); listaReg = new String[1]; listaReg[0] = regMng.GetRegistroCorrente().systemId; } else { listaReg = null; // ricerche e profilo } } ArrayList aL = new ArrayList(); if (listaReg != null) { for (int i = 0; i < listaReg.Length; i++) { aL.Add(listaReg[i]); listaRF = UserManager.getListaRegistriWithRF(this.Page, "1", listaReg[i]); for (int j = 0; j < listaRF.Length; j++) { aL.Add(listaRF[j].systemId); } } listaReg = new string[aL.Count]; aL.CopyTo(listaReg); } } catch (Exception ex) { throw new Exception("Registro non settato!"); } DocsPaWR.Oggetto[] listaObj; // E' inutile finire nel backend se la casella di testo è vuota (a parte il fatto che // la funzione, in questo caso, restituisce tutto l'oggettario) if (!String.IsNullOrEmpty(this.txt_cod_oggetto.Text.Trim())) { //In questo momento tralascio la descrizione oggetto che metto come stringa vuota listaObj = DocumentManager.getListaOggettiByCod(this.Page, listaReg, "", this.txt_cod_oggetto.Text); } else { listaObj = new DocsPaWR.Oggetto[] { new DocsPaWR.Oggetto() { descrizione = String.Empty, codOggetto = String.Empty } } }; if (listaObj.Length > 0) { this.txt_oggetto.Text = listaObj[0].descrizione; //this.txt_cod_oggetto.Text = listaObj[0].codOggetto; schedaDoc.oggetto.codOggetto = listaObj[0].codOggetto; schedaDoc.oggetto.descrizione = listaObj[0].descrizione; schedaDoc.oggetto.daAggiornare = true; DocumentManager.setDocumentoInLavorazione(schedaDoc); } else { RegisterClientScript("Codice_error", "alert('codice oggetto inesistente!');"); this.txt_oggetto.Text = ""; this.txt_cod_oggetto.Text = ""; //Azzero anche i dati nella scheda corrente in modo che non rimanga in memoria il vecchio //campo e codice oggetto!!! schedaDoc.oggetto.codOggetto = ""; schedaDoc.oggetto.descrizione = ""; DocumentManager.setDocumentoInLavorazione(schedaDoc); } } }
protected void btnUpdate_Click(object sender, EventArgs e) { ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "function", "<script>reallowOp();</script>", false); string errMsg = string.Empty; DocsPaWR.Oggetto oggetto = new DocsPaWR.Oggetto(); DocsPaWR.Registro registro = new DocsPaWR.Registro(); DocsPaWR.Oggetto oggettoDoc = new DocsPaWR.Oggetto(); #region controls //check on insert object bool result; if (this.GridSearchObject.SelectedIndex == -1) { errMsg = "ErrorObjectSelectRecordMod"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectSelectRecordMod", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true); return; } if (string.IsNullOrEmpty(this.TxtDescObject.Text)) { errMsg = "ErrorObjectNoObject"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectNoObject", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true); return; } //check on the length of the object (up to 2000 characters.) if (this.TxtDescObject.Text.Length > 2000) { errMsg = "ErrorObjectLength"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectLength", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true); return; } #endregion oggettoDoc.daAggiornare = true; int selRow = this.GridSearchObject.SelectedIndex; oggetto.descrizione = this.TxtDescObject.Text.Trim(); //.Replace("'", "''"); Escape gestito dai WS //Adding the object code if there if (!string.IsNullOrEmpty(this.TxtCodObject.Text.Trim())) { oggetto.codOggetto = this.TxtCodObject.Text.Trim(); //.Replace("'", "''"); Escape gestito dai WS } else { oggetto.codOggetto = string.Empty; } if (selRow > -1 && selRow < this.GridSearchObject.Rows.Count) { oggettoDoc.systemId = (GridSearchObject.Rows[selRow].Cells[(int)oggettario.systemid].FindControl("systemid") as Label).Text; oggettoDoc.descrizione = (GridSearchObject.Rows[selRow].Cells[(int)oggettario.description].FindControl("lblDescObject") as Label).Text; oggettoDoc.descrizione = oggettoDoc.descrizione; //.Replace("'", "''"); Escape gestito dai WS //recovery the registry of the selected object for editing Label lblRegCode = (Label)GridSearchObject.Rows[selRow].Cells[(int)oggettario.registrycode].FindControl("lblRegCode"); registro.codice = lblRegCode.Text; for (int regNum = 0; regNum < this.ObjectRegistryList.Length; regNum++) { if (this.ObjectRegistryList[regNum].codRegistro.ToLower().Equals(registro.codice.ToLower())) { registro.systemId = this.ObjectRegistryList[regNum].systemId; break; } } /* * 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) && !obj.systemId.Equals(oggettoDoc.systemId) 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) && !obj.systemId.Equals(oggettoDoc.systemId) select obj).Count() > 0) * { * errMsg = "ErrorObjectVoicePresent"; * ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectVoicePresent", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true); * return; * } */ if (string.IsNullOrEmpty(registro.systemId)) { registro = null; } oggettoDoc.codOggetto = (GridSearchObject.Rows[selRow].Cells[(int)oggettario.codobject].FindControl("lblCodObject") as Label).Text; try { result = ObjectManager.DeleteObject(this, oggettoDoc); if (result) { oggetto = ObjectManager.AddObject(this, oggetto, registro, ref errMsg); if (!string.IsNullOrEmpty(errMsg) || oggetto == null) //In the case of failure to enter recovery from deletion { oggetto = ObjectManager.AddObject(this, oggettoDoc, registro, ref errMsg); errMsg = "ErrorObjectPresent"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectPresent", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true); return; } if (this.ObjectstList != null && this.ObjectstList.Count() > 0 && (from o in ObjectstList where o.systemId.Equals(oggettoDoc.systemId) select o).FirstOrDefault() != null) { oggetto.codRegistro = registro != null ? registro.codice : string.Empty; //List<int> index = (from a in ObjectstList.Select((item, i) => new { obj = item, index = i }) where a.obj.systemId.Equals(oggettoDoc.systemId) select a.index).ToList(); int index = ObjectstList.Select((item, i) => new { obj = item, index = i }).First(item => item.obj.systemId.Equals(oggettoDoc.systemId)).index; ObjectstList[index] = oggetto; } } else { errMsg = "ErrorObjectPresent"; ScriptManager.RegisterStartupScript(this, this.GetType(), "ErrorObjectPresent", "parent.ajaxDialogModal('" + errMsg + "', 'warning', 'ATTENZIONE');", true); return; } } catch (Exception err) { throw new Exception("ERROR: " + err.Message); } } this.GridSearchObject.EditIndex = -1; this.GridSearchObject.SelectedIndex = -1; this.BtnOk.Enabled = false; this.ObjectBtnDelete.Enabled = false; this.TxtCodObject.Text = string.Empty; this.TxtDescObject.Text = string.Empty; (GridSearchObject.Rows[selRow].Cells[(int)oggettario.systemid].FindControl("systemid") as Label).Text = oggetto.systemId; (GridSearchObject.Rows[selRow].Cells[(int)oggettario.codobject].FindControl("lblCodObject") as Label).Text = oggetto.codOggetto; (GridSearchObject.Rows[selRow].Cells[(int)oggettario.description].FindControl("lblDescObject") as Label).Text = oggetto.descrizione; this.UpdPnlGridSearch.Update(); this.UpdPnlCodeObject.Update(); this.UpPnlButtons.Update(); }
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); } }