protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { ds_mainTableAdapters.listingTableAdapter listingTA = new ds_mainTableAdapters.listingTableAdapter(); ds_main.listingDataTable listingDT = new ds_main.listingDataTable(); ds_main.listingRow listingR = listingDT.NewlistingRow(); listingR["listing_id"] = tbListingID.Text; listingR["num_of_images"] = tbNumOfImages.Text; //listingR["ts"] = tbTimeStamp.Text; //listingR["path"] = tbPath.Text; listingDT.Rows.Add(listingR); listingTA.Update(listingDT); if (cbSale.Checked) { ds_mainTableAdapters.x_listing_typeTableAdapter x_listing_typeTA = new ds_mainTableAdapters.x_listing_typeTableAdapter(); ds_main.x_listing_typeDataTable x_listing_typeDT = new ds_main.x_listing_typeDataTable(); ds_main.x_listing_typeRow x_listing_typeR = x_listing_typeDT.Newx_listing_typeRow(); x_listing_typeR.listing_id = Convert.ToInt32(tbListingID.Text); x_listing_typeR.type_id = 100; x_listing_typeR.sort = MLS.getMaxSortByTypeID(100) + 1; x_listing_typeDT.Rows.Add(x_listing_typeR); x_listing_typeTA.Update(x_listing_typeDT); } if (cbRental.Checked) { ds_mainTableAdapters.x_listing_typeTableAdapter x_listing_typeTA = new ds_mainTableAdapters.x_listing_typeTableAdapter(); ds_main.x_listing_typeDataTable x_listing_typeDT = new ds_main.x_listing_typeDataTable(); ds_main.x_listing_typeRow x_listing_typeR = x_listing_typeDT.Newx_listing_typeRow(); x_listing_typeR.listing_id = Convert.ToInt32(tbListingID.Text); x_listing_typeR.type_id = 200; x_listing_typeR.sort = MLS.getMaxSortByTypeID(200) + 1; x_listing_typeDT.Rows.Add(x_listing_typeR); x_listing_typeTA.Update(x_listing_typeDT); } if (cbSale.Checked) { Response.Redirect("./listings.aspx?type_id=100"); } else if (cbRental.Checked) { Response.Redirect("./listings.aspx?type_id=200"); } } }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { ds_mainTableAdapters.listingTableAdapter listingTA = new ds_mainTableAdapters.listingTableAdapter(); ds_main.listingDataTable listingDT = listingTA.GetDataByID(Convert.ToInt32(Request.QueryString["id"].ToString())); listingDT.Rows[0]["selling_point"] = tbSellingPoint.Text; //listingDT.Rows[0]["price"] = tbPrice.Text.Replace("$", ""); listingDT.Rows[0]["listing_id"] = tbListingID.Text; listingDT.Rows[0]["num_of_images"] = tbNumOfImages.Text; //listingDT.Rows[0]["ts"] = tbTimeStamp.Text; //listingDT.Rows[0]["path"] = tbPath.Text; listingDT.Rows[0]["bed"] = tbBed.Text; listingDT.Rows[0]["bath"] = tbBath.Text; listingDT.Rows[0]["style"] = ddlStyle.SelectedValue; listingDT.Rows[0]["address"] = tbAddress.Text; listingDT.Rows[0]["city"] = tbCity.Text; listingDT.Rows[0]["zip"] = tbZip.Text; Debug.WriteLine(RTESafe(Request.Form["message"].ToString())); listingDT.Rows[0]["description"] = RTESafe(Request.Form["message"].ToString()); //bool featuredUpdated = false; if (cbFeatured.Checked) { //if (listingDT.Rows[0]["featured"].ToString() == "") //{ // featuredUpdated = true; //} //else //{ // if (!Convert.ToBoolean(listingDT.Rows[0]["featured"].ToString())) // { // featuredUpdated = true; // } //} listingDT.Rows[0]["featured"] = 1; listingDT.Rows[0]["featured_sort"] = MLS.getMaxFeaturedSort() + 1; } else { //if (listingDT.Rows[0]["featured"].ToString() == "") //{ // featuredUpdated = false; //} //else //{ // if (Convert.ToBoolean(listingDT.Rows[0]["featured"].ToString())) // { // featuredUpdated = true; // } //} listingDT.Rows[0]["featured"] = 0; } listingDT.Rows[0]["status"] = ddlStatus.SelectedValue; listingTA.Update(listingDT); int sort = 0; ds_mainTableAdapters.x_listing_typeTableAdapter x_listing_typeTA = new ds_mainTableAdapters.x_listing_typeTableAdapter(); if (cbSale.Checked) { ds_main.x_listing_typeDataTable x_listing_typeDT = x_listing_typeTA.GetDataByListingIDTypeID(Convert.ToInt32(tbListingID.Text), 100); if (x_listing_typeDT.Rows.Count > 0) { x_listing_typeDT.Rows[0]["price"] = Convert.ToDecimal(tbPrice.Text.Replace("$", "")); x_listing_typeTA.Update(x_listing_typeDT); } else//Not listed as 'Sale'. So add it! { x_listing_typeTA.InsertData(Convert.ToInt32(Request.QueryString["id"].ToString()), 100, Convert.ToDecimal(tbPrice.Text.Replace("$", "")), MLS.getMaxSortByTypeID(100) + 1); } } else { x_listing_typeTA.DeleteXListingTypeByListingIDTypeID(Convert.ToInt32(Request.QueryString["id"].ToString()), 100); } if (cbRental.Checked) { ds_main.x_listing_typeDataTable x_listing_typeDT = x_listing_typeTA.GetDataByListingIDTypeID(Convert.ToInt32(tbListingID.Text), 200); if (x_listing_typeDT.Rows.Count > 0) { x_listing_typeDT.Rows[0]["price"] = Convert.ToDecimal(tbRent.Text.Replace("$", "")); x_listing_typeTA.Update(x_listing_typeDT); } else//Not listed as 'Rental'. So add it! { x_listing_typeTA.InsertData(Convert.ToInt32(Request.QueryString["id"].ToString()), 200, Convert.ToDecimal(tbRent.Text.Replace("$", "")), MLS.getMaxSortByTypeID(200) + 1); } } else { x_listing_typeTA.DeleteXListingTypeByListingIDTypeID(Convert.ToInt32(Request.QueryString["id"].ToString()), 200); } MLS.InsertModifiedDate(); //ds_main.x_listing_typeDataTable x_listing_typeDT = x_listing_typeTA.GetDataByListingID(Convert.ToInt32(tbListingID.Text)); //if (x_listing_typeDT.Rows.Count > 0) // sort = Convert.ToInt32(x_listing_typeDT.Rows[0]["sort"].ToString()); //x_listing_typeTA.DeleteXListingTypeByListingID(Convert.ToInt32(Request.QueryString["id"].ToString())); //if (cbSale.Checked) //{ // x_listing_typeTA.InsertData(Convert.ToInt32(Request.QueryString["id"].ToString()), // 100, // Convert.ToDecimal(tbPrice.Text.Replace("$", "")), // MLS.getMaxSortByTypeID(100) + 1); // //ds_main.x_listing_typeDataTable x_listing_typeDT = new ds_main.x_listing_typeDataTable(); // //ds_main.x_listing_typeRow x_listing_TypeR = x_listing_typeDT.Newx_listing_typeRow(); // //x_listing_TypeR.listing_id = Convert.ToInt32(Request.QueryString["id"].ToString()); // //x_listing_TypeR.type_id = 100; // //x_listing_TypeR.price = Convert.ToDecimal(tbPrice.Text.Replace("$", "")); // //x_listing_TypeR.sort = MLS.getMaxSortByTypeID(100)+1; // //x_listing_typeDT.Addx_listing_typeRow(x_listing_TypeR); // //x_listing_typeTA.Update(x_listing_typeDT); //} //if (cbRental.Checked) //{ // x_listing_typeTA.InsertData(Convert.ToInt32(Request.QueryString["id"].ToString()), // 200, // Convert.ToDecimal(tbPrice.Text.Replace("$", "")), // MLS.getMaxSortByTypeID(200) + 1); // //ds_main.x_listing_typeDataTable x_listing_typeDT = new ds_main.x_listing_typeDataTable(); // //ds_main.x_listing_typeRow x_listing_TypeR = x_listing_typeDT.Newx_listing_typeRow(); // //x_listing_TypeR.listing_id = Convert.ToInt32(Request.QueryString["id"].ToString()); // //x_listing_TypeR.type_id = 200; // //x_listing_TypeR.sort = MLS.getMaxSortByTypeID(200) + 1; // //x_listing_TypeR.price = Convert.ToDecimal(tbRent.Text.Replace("$", "")); // //x_listing_typeDT.Addx_listing_typeRow(x_listing_TypeR); // //x_listing_typeTA.Update(x_listing_typeDT); //} //ds_main.x_listing_typeDataTable x_listing_typeDT = x_listing_typeTA.GetDataByListingID(Convert.ToInt32(Request.QueryString["id"].ToString())); ////x_listing_typeDT.Rows[0]["price"] = "100"; //foreach (ds_main.x_listing_typeRow r in x_listing_typeDT.Rows) //{ // if (r["type_id"].ToString() == "100") // { // if (cbSale.Checked) // { // r["price"] = tbPrice.Text.Replace("$", ""); // } // } // if (r["type_id"].ToString() == "200") // { // if (cbRental.Checked) // { // r["price"] = tbRent.Text.Replace("$", ""); // } // } //} //x_listing_typeTA.Update(x_listing_typeDT); //if (featuredUpdated) //{ // Response.Redirect("./"); //} //else if (cbSale.Checked) if (cbSale.Checked) { Response.Redirect("./listings.aspx?type_id=100&id=" + Request.QueryString["id"].ToString()); } else if (cbRental.Checked) { Response.Redirect("./listings.aspx?type_id=200&id=" + Request.QueryString["id"].ToString()); } } }