Exemplo n.º 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();
        }
Exemplo n.º 2
0
        /// <summary>
        /// loads the subjects of the costumer
        /// </summary>
        private void LoadCostumerSubjects()
        {
            CostumerSubjects.Clear();
            CostumerAdvancedSubjects.Clear();

            CustomSqlConnection con = new CustomSqlConnection();

            if (con.ConnectError())
            {
                return;
            }
            string RawCommand = "use greenLib Select f_kurzform, f_langform, f_id from t_s_fach_kunde " +
                                "left join t_s_faecher on f_id = fs_fachid WHERE fs_kundenid = @0 and fs_lk = 1";
            SqlDataReader dr = con.ExcecuteCommand(RawCommand, CostumerId);

            while (dr.Read())
            {
                Subject subject = new Subject();
                subject.SubjectId        = int.Parse(dr["f_id"].ToString());
                subject.SubjectNameLong  = dr["f_langform"].ToString();
                subject.SubjectNameShort = dr["f_kurzform"].ToString();
                CostumerAdvancedSubjects.Add(subject);
            }
            dr.Close();
            RawCommand = "use greenLib Select f_kurzform, f_langform, f_id from t_s_fach_kunde " +
                         "left join t_s_faecher on f_id = fs_fachid WHERE fs_kundenid = @0";
            dr = con.ExcecuteCommand(RawCommand, CostumerId);
            while (dr.Read())
            {
                Subject subject = new Subject();
                subject.SubjectId        = int.Parse(dr["f_id"].ToString());
                subject.SubjectNameLong  = dr["f_langform"].ToString();
                subject.SubjectNameShort = dr["f_kurzform"].ToString();
                CostumerSubjects.Add(subject);
            }
            //for (int i = CostumerAdvancedSubjects.Count; i < 2; i++)
            //{
            //    CostumerAdvancedSubjects.Add(new Subject());
            //}
            dr.Close();
            con.Close();
        }