public static void saveOnlyEditSurvey(Ankieta ankieta)
        {
            String connStr = ConfigurationManager.ConnectionStrings["inzSNMConnectionString"].ConnectionString;
            using (SqlConnection Sqlconn = new SqlConnection(connStr))
            {
                try
                {
                    Sqlconn.Open();
                    SqlCommand command = new SqlCommand("edit_survey", Sqlconn);
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.Add("@id_ankiety", SqlDbType.Int).Value = ankieta.Id_ankiety;
                    command.Parameters.Add("@nazwa", SqlDbType.VarChar).Value = ankieta.Nazwa;
                    command.Parameters.Add("@opis", SqlDbType.VarChar).Value = ankieta.Opis_ankiety;
                    command.Parameters.Add("@dataZak", SqlDbType.DateTime).Value = ankieta.Data_zak;
                    command.Parameters.Add("@active", SqlDbType.Int).Value = 1;//do zmiay po zaktualizowaniu modelu
                    command.Parameters.Add("@Typ", SqlDbType.VarChar).Value = ankieta.Type;
                    command.ExecuteNonQuery();

                }
                catch (SqlException ex)
                {
                    throw new Exception("Zapis ankiety o ID " + ankieta.Id_ankiety + " nie powiódł się");
                }
            }
        }
        public static inzPJATKSNM.Models.Ankieta getSurvey(int id)
        {
            inzPJATKSNM.Models.Ankieta Survey = new inzPJATKSNM.Models.Ankieta();
            try
            {
                String connStr = ConfigurationManager.ConnectionStrings["inzSNMConnectionString"].ConnectionString;
                using (SqlConnection Sqlcon = new SqlConnection(connStr))
                {
                    Sqlcon.Open();
                    string query = "select Nazwa,Opis_ankiety,Data_rozp,Data_zak from Ankieta where id_ankiety like @ID;";
                    using (SqlCommand command = new SqlCommand(query, Sqlcon))
                    {
                        command.Parameters.Add("@ID", SqlDbType.Int);
                        command.Parameters["@ID"].Value = id;
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {

                                Survey.Nazwa = reader.GetString(0);
                                Survey.Opis_ankiety = reader.GetString(1);
                                Survey.Data_rozp = reader.GetDateTime(2);
                                Survey.Data_zak = reader.GetDateTime(3);

                            }
                        }
                    }
                    Sqlcon.Close();
                }
            }
            catch (Exception e)
            {
                throw new Exception("Nie udało się pobrać ankiety o ID " + id);
            }

            return Survey;
        }
 public static void saveEditsurvey(Ankieta ankieta,Dictionary<string,Dzieło> zdjPoEdycji)
 {
     List<int> listaIdPoEdycji = new List<int>();
     try
     {
         foreach (string url in zdjPoEdycji.Keys)
         {
             listaIdPoEdycji.Add(getPhotoId(url));
         }
         saveOnlyEditSurvey(ankieta);
         saveEditPhotos(listaIdPoEdycji, ankieta.Id_ankiety);
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache)
            {
                HttpContext.Current.Cache.Remove((string)entry.Key);
            }

            Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);

            Response.Cache.SetNoStore();

            if (err !=null)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "pop", "failOpenModal();", true);
            }
            if (!IsPostBack)
            {
                if (Request.QueryString["Id"] != null)
                {
                    currentValue = "";
                    currentKey = new Int32();
                    int id = int.Parse(Request.QueryString["Id"]);
                    try
                    {
                        if (surveyPhotos.Count == 0)
                        {
                            surveyPhotos = inzPJATKSNM.Controllers.EditExistingSurveyController.getSurveyPhotos(id);
                        }
                        if (photoFromDB.Count == 0)
                        {
                            loadPhotosFromDB();
                        }
                        if (filteredList.Count == 0)
                        {
                            filteredList = getPhotoFromDB();
                        }

                        ankieta = inzPJATKSNM.Controllers.EditExistingSurveyController.getSurvey(id);
                    }
                    catch (Exception ex)
                    {
                        Response.Redirect("ShowSurveys.aspx?err=" + ex.Message);
                    }

                    example1.Value = ankieta.Data_zak.ToString();
                    SurveyNameTextBox1.Text = ankieta.Nazwa;
                    ServeyDescribtionTextBox1.Text = ankieta.Opis_ankiety;
                    Data_zakLAb.Text = ankieta.Data_rozp.ToString();

                }
                else
                {
                    Response.Redirect("ShowSurveys.aspx?err=PusteId");
                }
            }
        }