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(); }
public void Delete(REF_Offers oREF_Offers) { DBConnecton db; db = new DBConnecton(); string sqlQuery; SqlCommand oSqlCommand; try { sqlQuery = "DELETE FROM `mainoffer` WHERE `mainoffer`.`idmainoffer` = " + oREF_Offers.ID + ""; //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; } }
public DataTable SelectOffersByID(REF_Offers oREF_Offers) { DBConnecton db; db = new DBConnecton(); DataTable dataTable = new DataTable(); string query = "SELECT * FROM `mainoffer` WHERE `idmainoffer`='" + oREF_Offers.ID + "'"; //Open connection if (db.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, db.getConnetion()); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); DataSet ds = new DataSet(); ds.Tables.Add(dataTable); ds.EnforceConstraints = false; dataTable.Load(dataReader); dataReader.Close(); //close Connection db.CloseConnection(); //return list to be displayed return(dataTable); } else { return(dataTable); } }
public void Update(REF_Offers oREF_Offers) { DBConnecton db; db = new DBConnecton(); string sqlQuery; SqlCommand oSqlCommand; try { sqlQuery = "UPDATE `mainoffer` SET `offer_type` = '" + oREF_Offers.OFFER_TYPE + "', `offer_id` = '" + oREF_Offers.Offer_ID + "', `offer_name` = '" + oREF_Offers.OFFER_NAME + "', `offer_start_date` = '" + oREF_Offers.START_DATE + "', " + "`offer_end_date` = '" + oREF_Offers.END_DATE + "', `offer_price_min` = '" + oREF_Offers.MIN_PRICE + "', `offer_price_max` = '" + oREF_Offers.MAX_PRICE + "', `offer_description` = '" + oREF_Offers.DESCCRIPTION + "' WHERE `mainoffer`.`idmainoffer` = " + oREF_Offers.ID + ""; //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; } }
public void Insert(REF_Offers oREF_Offers) { DBConnecton db; db = new DBConnecton(); string sqlQuery; SqlCommand oSqlCommand; try { sqlQuery = "INSERT INTO `mainoffer` (`idmainoffer`, `offer_type`, `offer_id`, `offer_name`, `offer_start_date`, `offer_end_date`, `offer_price_min`, `offer_price_max`, `offer_description`)" + " VALUES (NULL, '" + oREF_Offers.OFFER_TYPE + "', '" + oREF_Offers.Offer_ID + "', '" + oREF_Offers.OFFER_NAME + "', '" + oREF_Offers.START_DATE + "', '" + oREF_Offers.END_DATE + "', '" + oREF_Offers.MIN_PRICE + "', '" + oREF_Offers.MAX_PRICE + "', '" + oREF_Offers.DESCCRIPTION + "');"; //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; } }
protected void btnsubmitoffers_Click(object sender, EventArgs e) { DAC_BookServices oDAC_BookServices = new DAC_BookServices(); REF_BookServices oREF_BookServices = new REF_BookServices(); oREF_BookServices.CusID = Convert.ToInt32(dropCusotmer.Value); oREF_BookServices.ServiceID = Convert.ToInt32(dropService.Value); oREF_BookServices.OfferID = Convert.ToInt32(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_BookServices.OfferPrice = dt.Rows[0][6].ToString(); DAC_Service oDAC_Service = new DAC_Service(); REF_Service oREF_Service = new REF_Service(); oREF_Service.ID = Convert.ToInt32(dropService.Value); dt = oDAC_Service.SelectServiceByID(oREF_Service); Double ServicePrice = Double.Parse(dt.Rows[0][4].ToString()); Double Total = ServicePrice - OfferPrice; oREF_BookServices.ServicePrice = dt.Rows[0][3].ToString(); oREF_BookServices.TotalPrice = Total.ToString(); oDAC_BookServices.Insert(oREF_BookServices); LoadData(); }
protected void btndelete_Click(object sender, EventArgs e) { DAV_Offers oDAV_Offers = new DAV_Offers(); REF_Offers oREF_Offers = new REF_Offers(); oREF_Offers.ID = Convert.ToInt32(OffersID);; oDAV_Offers.Delete(oREF_Offers); Response.Redirect("./frmOffers.aspx", true); }
protected void btnupdate_Click(object sender, EventArgs e) { DAV_Offers oDAV_Offers = new DAV_Offers(); REF_Offers oREF_Offers = new REF_Offers(); oREF_Offers.ID = Convert.ToInt32(OffersID);; oREF_Offers.OFFER_TYPE = drpofferType.Value; oREF_Offers.Offer_ID = offerID.Text; oREF_Offers.OFFER_NAME = offersName.Text; oREF_Offers.START_DATE = Request.Form["start"]; oREF_Offers.END_DATE = Request.Form["end"]; oREF_Offers.MIN_PRICE = MimumPrice.Text; oREF_Offers.MAX_PRICE = MaxmumPrice.Text; oREF_Offers.DESCCRIPTION = offerDesc.Text; oDAV_Offers.Update(oREF_Offers); Response.Redirect("./frmOffers.aspx", true); }
public void LoadData(REF_Offers oREF_Offers) { DataTable dt; DAV_Offers oDAV_Offers = new DAV_Offers(); oREF_Offers.ID = Convert.ToInt32(OffersID); dt = oDAV_Offers.SelectOffersByID(oREF_Offers); drpofferType.Value = dt.Rows[0][1].ToString(); offerID.Text = dt.Rows[0][2].ToString(); offersName.Text = dt.Rows[0][3].ToString(); //Request.Form["start"] = dt.Rows[0][4].ToString(); //Request.Form["end"] = dt.Rows[0][5].ToString(); MimumPrice.Text = dt.Rows[0][6].ToString(); MaxmumPrice.Text = dt.Rows[0][7].ToString(); offerDesc.Text = dt.Rows[0][8].ToString(); btnupdate.Visible = true; btndelete.Visible = true; btnsubmitoffers.Visible = false; }
protected void Button1_Click(object sender, EventArgs e) { 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()); DAC_Service oDAC_Service = new DAC_Service(); REF_Service oREF_Service = new REF_Service(); oREF_Service.ID = Convert.ToInt32(dropService.Value); dt = oDAC_Service.SelectServiceByID(oREF_Service); Double ServicePrice = Double.Parse(dt.Rows[0][4].ToString()); Double Total = ServicePrice - OfferPrice; lbltotal.InnerText = "Total Cost Rs." + Total.ToString(); }
protected void Unnamed1_Click(object sender, EventArgs e) { try { DAV_Offers oDAV_Offers = new DAV_Offers(); REF_Offers oREF_Offers = new REF_Offers(); oREF_Offers.OFFER_TYPE = drpofferType.Value; oREF_Offers.Offer_ID = offerID.Text; oREF_Offers.OFFER_NAME = offersName.Text; oREF_Offers.START_DATE = Request.Form["start"]; oREF_Offers.END_DATE = Request.Form["end"]; oREF_Offers.MIN_PRICE = MimumPrice.Text; oREF_Offers.MAX_PRICE = MaxmumPrice.Text; oREF_Offers.DESCCRIPTION = offerDesc.Text; oDAV_Offers.Insert(oREF_Offers); ShowMessage("Data Insert successfully!"); }catch (Exception ex) { ShowMessage("Something went wrong! Please try again!"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btndelete.Visible = false; btnupdate.Visible = false; if (Request.QueryString["ID"] != null) { btndelete.Visible = true; btnupdate.Visible = true; btnsubmitoffers.Visible = false; OffersID = Request.QueryString["ID"]; REF_Offers oREF_Offers = new REF_Offers(); oREF_Offers.ID = Convert.ToInt32(OffersID); LoadData(oREF_Offers); } else { } } OffersID = Request.QueryString["ID"]; LoadData(); }