/// <summary> /// Aggiunge un utente al gruppo organigramma e poi lo collega ad uno specifico nodo dell'organigramma stesso /// </summary> /// <param name="FlowChartUserToAdd"></param> /// <returns></returns> bool AggiungiUtenteAdOrganigramma(FlowChartUser FlowChartUserToAdd) { MetaData meta_flowchartuser = Meta.Dispatcher.Get("flowchartuser"); string idcustomuser = FlowChartUserToAdd.idcustomuser; string login = idcustomuser; // assunzione base bool res = AggiungiUtenteAGruppoOrganigramma(idcustomuser, login); if (!res) { return(false); } object idflowchart = Conn.DO_READ_VALUE("flowchart", QHS.AppAnd(QHS.CmpEq("codeflowchart", FlowChartUserToAdd.flowchartcode), QHS.CmpEq("ayear", Conn.GetSys("esercizio"))) , "idflowchart"); if (idflowchart == null || idflowchart == DBNull.Value) { MessageBox.Show(this, "Il codice " + FlowChartUserToAdd.flowchartcode + " non è presente nella tabella organigramma dell'anno " + Conn.GetSys("esercizio").ToString() + ".", "Errore"); return(false); } string f = QHS.AppAnd(QHS.CmpEq("idcustomuser", idcustomuser), QHS.CmpEq("idflowchart", idflowchart), QHS.CmpEq("title", FlowChartUserToAdd.title)); if (Conn.RUN_SELECT_COUNT("flowchartuser", f, false) > 0) { return(true); //già presente } DataTable TFlowchartUser = Conn.CreateTableByName("flowchartuser", "*"); DataSet D = new DataSet(); D.Tables.Add(TFlowchartUser); MetaData.SetDefault(TFlowchartUser, "idflowchart", idflowchart); MetaData.SetDefault(TFlowchartUser, "idcustomuser", idcustomuser); meta_flowchartuser.SetDefaults(TFlowchartUser); DataRow fu = meta_flowchartuser.Get_New_Row(null, TFlowchartUser); fu["title"] = FlowChartUserToAdd.title; fu["idsor01"] = FlowChartUserToAdd.idsor01; fu["idsor02"] = FlowChartUserToAdd.idsor02; fu["idsor03"] = FlowChartUserToAdd.idsor03; fu["idsor04"] = FlowChartUserToAdd.idsor04; fu["idsor05"] = FlowChartUserToAdd.idsor05; fu["all_sorkind01"] = FlowChartUserToAdd.all_sorkind01; fu["all_sorkind02"] = FlowChartUserToAdd.all_sorkind02; fu["all_sorkind03"] = FlowChartUserToAdd.all_sorkind03; fu["all_sorkind04"] = FlowChartUserToAdd.all_sorkind04; fu["all_sorkind05"] = FlowChartUserToAdd.all_sorkind05; fu["sorkind01_withchilds"] = FlowChartUserToAdd.sorkind01_withchilds; fu["sorkind02_withchilds"] = FlowChartUserToAdd.sorkind02_withchilds; fu["sorkind03_withchilds"] = FlowChartUserToAdd.sorkind03_withchilds; fu["sorkind04_withchilds"] = FlowChartUserToAdd.sorkind04_withchilds; fu["sorkind05_withchilds"] = FlowChartUserToAdd.sorkind05_withchilds; fu["flagdefault"] = FlowChartUserToAdd.flagdefault; fu["start"] = FlowChartUserToAdd.start == DBNull.Value? new DateTime(1900, 1, 1): FlowChartUserToAdd.start; Easy_PostData pd = new Easy_PostData(); pd.InitClass(D, Conn); if (!pd.DO_POST()) { MessageBox.Show(this, "Errore nel salvataggio dei dati in AggiungiUtenteAdOrganigramma", "Errore"); return(false); } else { return(true); } }