Exemplo n.º 1
0
        public void Insert(REF_EnrollCourse oREF_EnrollCourse)
        {
            DBConnecton db;

            db = new DBConnecton();
            string     sqlQuery;
            SqlCommand oSqlCommand;

            try

            {
                sqlQuery = "INSERT INTO `tblenrollcourse` (`ID`, `CusID`, `CourseID`, `Status`, `OfferID`, `offer_prices`, `Course_price`, `Total`)" +
                           "VALUES (NULL, '" + oREF_EnrollCourse.CusID + "', '" + oREF_EnrollCourse.CourseID + "', '0', '" + oREF_EnrollCourse.OfferID + "', '" + oREF_EnrollCourse.offer_prices + "', '" + oREF_EnrollCourse.Course_price + "', '" + oREF_EnrollCourse.Total + "');";

                //open connection
                if (db.OpenConnection() == true)
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(sqlQuery, db.getConnetion());

                    //Execute command
                    cmd.ExecuteNonQuery();

                    //close connection
                    db.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        protected void btnsubmitoffers_Click(object sender, EventArgs e)
        {
            DAC_EnrollCourse oDAC_EnrollCourse = new DAC_EnrollCourse();
            REF_EnrollCourse oREF_EnrollCourse = new REF_EnrollCourse();

            oREF_EnrollCourse.CusID    = dropCusotmer.Value;
            oREF_EnrollCourse.CourseID = dropCourse.Value;
            oREF_EnrollCourse.OfferID  = dropoffers.Value;
            DataTable  dt;
            DAV_Offers oDAV_Offers = new DAV_Offers();
            REF_Offers oREF_Offers = new REF_Offers();

            oREF_Offers.ID = Convert.ToInt32(dropoffers.Value);
            dt             = oDAV_Offers.SelectOffersByID(oREF_Offers);
            Double OfferPrice = Double.Parse(dt.Rows[0][6].ToString());

            oREF_EnrollCourse.offer_prices = dt.Rows[0][6].ToString();

            DAV_Cources oDAV_Cources = new DAV_Cources();
            REF_Course  oREF_Course  = new REF_Course();

            oREF_Course.ID = Convert.ToInt32(dropCourse.Value);
            dt             = oDAV_Cources.SelectCourseByID(oREF_Course);
            Double CoursePrice = Double.Parse(dt.Rows[0][4].ToString());

            Double Total = CoursePrice - OfferPrice;

            oREF_EnrollCourse.Course_price = dt.Rows[0][3].ToString();

            oREF_EnrollCourse.Total = Total.ToString();
            oDAC_EnrollCourse.Insert(oREF_EnrollCourse);
            LoadData();
        }