Exemple #1
0
        public static bool SalvaDati(ref Valutazione valutazione, ref string sMsg)
        {
            bool bResult;

            try
            {
                var sb = new StringBuilder();

                var arParams = new List <MySqlLiteParameter>
                {
                    new MySqlLiteParameter("@strutturale", DbType.String, valutazione.Strutturale),
                    new MySqlLiteParameter("@cranio_sacrale", DbType.String, valutazione.CranioSacrale),
                    new MySqlLiteParameter("@ak_ortodontica", DbType.String, valutazione.AkOrtodontica),
                    new MySqlLiteParameter("@id_paziente", DbType.Int32, valutazione.IdPaziente),
                    new MySqlLiteParameter("@id_consulto", DbType.Int32, valutazione.IdConsulto)
                };


                if (valutazione.ID == -1)
                {
                    sb.Append("INSERT INTO ");
                    sb.Append("valutazione");
                    sb.Append("( strutturale, cranio_sacrale, ak_ortodontica, id_paziente, id_consulto)");
                    sb.Append(" VALUES ");
                    sb.Append("( @strutturale, @cranio_sacrale, @ak_ortodontica, @id_paziente, @id_consulto)");

                    int newID;
                    SqlLiteHelper.Insert(sb.ToString(), arParams, out newID);
                    valutazione.ID = newID;
                }
                else
                {
                    arParams.Add(new MySqlLiteParameter("@ID", DbType.Int32, valutazione.ID));


                    sb.Append("UPDATE ");
                    sb.Append("valutazione");
                    sb.Append(" SET ");
                    sb.Append("strutturale=@strutturale,");
                    sb.Append("cranio_sacrale=@cranio_sacrale,");
                    sb.Append("ak_ortodontica=@ak_ortodontica,");
                    sb.Append("id_paziente=@id_paziente,");
                    sb.Append("id_consulto=@id_consulto");
                    sb.Append(" WHERE ");
                    sb.Append("ID = @ID");

                    SqlLiteHelper.Update(sb.ToString(), arParams);
                }

                bResult = true;
            }
            catch (Exception ex)
            {
                bResult = false;
                sMsg    = ex.Message;
            }

            return(bResult);
        }
Exemple #2
0
        public static bool SalvaDati(ref Trattamento trattamento, ref string sMsg)
        {
            bool bResult;

            try
            {
                var sb = new StringBuilder();

                var arParams = new List <MySqlLiteParameter>
                {
                    new MySqlLiteParameter("@data", DbType.DateTime, trattamento.Data),
                    new MySqlLiteParameter("@descrizione", DbType.String, trattamento.Descrizione),
                    new MySqlLiteParameter("@id_paziente", DbType.Int32, trattamento.IdPaziente),
                    new MySqlLiteParameter("@id_consulto", DbType.Int32, trattamento.IdConsulto)
                };

                if (trattamento.ID == -1)
                {
                    sb.Append("INSERT INTO ");
                    sb.Append("trattamento");
                    sb.Append("( data, descrizione,id_paziente, id_consulto )");
                    sb.Append(" VALUES ");
                    sb.Append("( @data, @descrizione, @id_paziente, @id_consulto )");

                    int newID;
                    SqlLiteHelper.Insert(sb.ToString(), arParams, out newID);
                    trattamento.ID = newID;
                }
                else
                {
                    arParams.Add(new MySqlLiteParameter("@ID", DbType.Int32, trattamento.ID));

                    sb.Append("UPDATE ");
                    sb.Append("trattamento");
                    sb.Append(" SET ");
                    sb.Append("data=@data,");
                    sb.Append("descrizione=@descrizione,");
                    sb.Append("id_paziente=@id_paziente,");
                    sb.Append("id_consulto=@id_consulto");
                    sb.Append(" WHERE ");
                    sb.Append("ID = @ID");

                    SqlLiteHelper.Update(sb.ToString(), arParams);
                }

                bResult = true;
            }
            catch (Exception ex)
            {
                bResult = false;
                sMsg    = ex.Message;
            }

            return(bResult);
        }