예제 #1
0
        /// <summary>
        /// adds the subjects to the specific costumer
        /// </summary>
        private void AddSubjectsToCostumer()
        {
            CustomSqlConnection con = new CustomSqlConnection();

            if (con.ConnectError())
            {
                return;
            }
            string command = "INSERT INTO [dbo].[t_s_fach_kunde] (fs_kundenid, fs_fachid, fs_lk) VALUES (@costumerId, @subjectId, @isAdvanced)";

            for (int i = 0; i < CostumerSubjects.Count; i++)
            {
                SqlCommand cmd = new SqlCommand(command, con.Con);
                cmd.Parameters.AddWithValue("@costumerId", CostumerId);
                cmd.Parameters.AddWithValue("@subjectId", subjectHelper.AddOrGetSubject(CostumerSubjects[i].SubjectNameShort).SubjectId);
                if (CostumerAdvancedSubjects.Contains(CostumerSubjects[i]))
                {
                    cmd.Parameters.AddWithValue("@isAdvanced", true);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@isAdvanced", false);
                }
                cmd.ExecuteNonQuery();
            }
            con.Close();
        }