partial void UpdateSurvey(Survey instance);
 partial void DeleteSurvey(Survey instance);
 partial void InsertSurvey(Survey instance);
        private void button1_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog op = new OpenFileDialog())
            {
                op.Filter = "CSV Files|*.csv";
                if (op.ShowDialog() == DialogResult.OK)
                {
                    StreamReader reader = new StreamReader(op.FileName);
                    reader.ReadLine();
                    string line = "";
                    while ((line = reader.ReadLine()) != null)
                    {
                        //Departure,Arrival,Age,Gender,CabinType,Q1,Q2,Q3,Q4

                        string[] data = line.Split(',');

                        string departure = data[0] == "" ? null : data[0];
                        string arrival   = data[1] == "" ? null : data[1];
                        int?   age       = data[2] == "" ? null : (int?)int.Parse(data[2]);
                        string gender    = data[3] == "" ? null : data[3];
                        string cabinType = data[4] == "" ? null : data[4];

                        int?a1 = data[5] == "0" ? null : (int?)int.Parse(data[5]);
                        int?a2 = data[6] == "0" ? null : (int?)int.Parse(data[6]);
                        int?a3 = data[7] == "0" ? null : (int?)int.Parse(data[7]);
                        int?a4 = data[8] == "0" ? null : (int?)int.Parse(data[8]);


                        Survey s = new Survey()
                        {
                            SurveyDate = new DateTime(2017, 7, 1),
                            Departure  = departure,
                            Arrival    = arrival,
                            CabinType  = cabinType,
                            Age        = age,
                            Gender     = gender
                        };
                        db.Surveys.InsertOnSubmit(s);
                        db.SubmitChanges();

                        DetailSurvey ds1 = new DetailSurvey()
                        {
                            SurveyID   = s.ID,
                            QuestionID = 1,
                            AnswerID   = a1
                        };
                        db.DetailSurveys.InsertOnSubmit(ds1);
                        db.SubmitChanges();


                        DetailSurvey ds2 = new DetailSurvey()
                        {
                            SurveyID   = s.ID,
                            QuestionID = 2,
                            AnswerID   = a2
                        };
                        db.DetailSurveys.InsertOnSubmit(ds2);
                        db.SubmitChanges();


                        DetailSurvey ds3 = new DetailSurvey()
                        {
                            SurveyID   = s.ID,
                            QuestionID = 3,
                            AnswerID   = a3
                        };
                        db.DetailSurveys.InsertOnSubmit(ds3);
                        db.SubmitChanges();


                        DetailSurvey ds4 = new DetailSurvey()
                        {
                            SurveyID   = s.ID,
                            QuestionID = 4,
                            AnswerID   = a4
                        };
                        db.DetailSurveys.InsertOnSubmit(ds4);
                        db.SubmitChanges();
                    }

                    MessageBox.Show("Test");
                }
            }
        }
Esempio n. 5
0
 private void detach_Surveys(Survey entity)
 {
     this.SendPropertyChanging();
     entity.CabinType1 = null;
 }
Esempio n. 6
0
 private void detach_Surveys1(Survey entity)
 {
     this.SendPropertyChanging();
     entity.Airport1 = null;
 }
Esempio n. 7
0
 private void attach_Surveys1(Survey entity)
 {
     this.SendPropertyChanging();
     entity.Airport1 = this;
 }