Esempio n. 1
0
        public void EditSubject(mst_subject mst)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    mst_sessionMain session = new mst_sessionMain();

                    mst.session = session.findActive_finalSession();

                    string query = @"UPDATE mst_subject 
                                    SET
                                        subject_name = @subject_name
                                    WHERE
                                        subject_id = @subject_id
                                            AND session = @session";

                    con.Execute(query, mst);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public void AddSubject(mst_subject mst)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString()))
                {
                    mst_sessionMain session = new mst_sessionMain();

                    string query = "INSERT INTO mst_subject (session,subject_id,subject_name) VALUES (@session,@subject_id,@subject_name)";

                    string maxid = @"SELECT 
                                        IFNULL(MAX(subject_id), 0) + 1
                                    FROM
                                        mst_subject
                                    WHERE
                                        session = (SELECT
                                                session
                                            FROM
                                                mst_session
                                            WHERE
                                                session_finalize = 'Y')";

                    int id = con.ExecuteScalar <int>(maxid);


                    mst.session      = session.findFinal_Session();
                    mst.subject_id   = id;
                    mst.subject_name = mst.subject_name.Trim();

                    con.Execute(query, new
                    {
                        mst.session,
                        mst.subject_id,
                        mst.subject_name
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }