Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
BiBD_otchyot_k_kursachu.doc
Скачиваний:
1
Добавлен:
01.05.2025
Размер:
1.05 Mб
Скачать

Код страницы Shop.Aspx.Cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Net.Mail;

public partial class _Default : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

GridView1.Visible = true;

GridViewRow row = GridView1.Rows[0];

int count = GridView1.Columns.Count;

int rows_count = GridView1.Rows.Count;

for (int i = 0; i < rows_count; i++)

{

row = GridView1.Rows[i];

if ((row.Cells[1].Text == Application["globName"].ToString()) && (Application["globName"] != " "))

{

GridView1.Rows[i].Visible = true;

}

else

{

GridView1.Rows[i].Visible = false;

}

}

}

protected void DropDownList1_TextChanged(object sender, EventArgs e)

{

GridViewRow row = GridView1.Rows[0];

int count = GridView1.Columns.Count;

int rows_count = GridView1.Rows.Count;

if (DropDownList1.SelectedIndex == 0)

{

GridView1.Visible = true;

for (int i = 0; i < rows_count; i++)

{

row = GridView1.Rows[i];

if (row.Cells[1].Text == DropDownList1.SelectedValue)

{

GridView1.Rows[i].Visible = true;

Application["globName"] = row.Cells[1].Text;

}

else

{

GridView1.Rows[i].Visible = false;

}

}

}

if (DropDownList1.SelectedIndex == 1)

{

GridView1.Visible = true;

for (int i = 0; i < rows_count; i++)

{

row = GridView1.Rows[i];

if (row.Cells[1].Text == DropDownList1.SelectedValue)

{

GridView1.Rows[i].Visible = true;

Application["globName"] = row.Cells[1].Text;

}

else

{

GridView1.Rows[i].Visible = false;

}

}

}

if (DropDownList1.SelectedIndex == 2)

{

GridView1.Visible = true;

for (int i = 0; i < rows_count; i++)

{

row = GridView1.Rows[i];

if (row.Cells[1].Text == DropDownList1.SelectedValue)

{

GridView1.Rows[i].Visible = true;

Application["globName"] = row.Cells[1].Text;

}

else

{

GridView1.Rows[i].Visible = false;

}

}

}

if (DropDownList1.SelectedIndex == 3)

{

GridView1.Visible = true;

for (int i = 0; i < rows_count; i++)

{

row = GridView1.Rows[i];

if (row.Cells[1].Text == DropDownList1.SelectedValue)

{

GridView1.Rows[i].Visible = true;

Application["globName"] = row.Cells[1].Text;

}

else

{

GridView1.Rows[i].Visible = false;

}

}

}

}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

{

GridViewRow row = GridView1.Rows[GridView1.SelectedIndex];

int rows_count = GridView2.Rows.Count;

bool a = false;

if (rows_count == 0)

{

SqlDataSource1.InsertCommand = "INSERT INTO temp_table(Good_name,Good_price,Доступ_кол) VALUES ('" + row.Cells[2].Text + "','" + row.Cells[3].Text + "','" + row.Cells[4].Text + "')";

SqlDataSource1.Insert();

}

else

{

for (int i = 0; i < rows_count; i++)

{

GridViewRow row2 = GridView2.Rows[i];

if (row.Cells[2].Text == row2.Cells[1].Text)

{

a = true;

break;

}

}

if (!a)

{

SqlDataSource1.InsertCommand = "INSERT INTO temp_table(Good_name,Good_price,Доступ_кол) VALUES ('" + row.Cells[2].Text + "','" + row.Cells[3].Text + "','" + row.Cells[4].Text + "')";

SqlDataSource1.Insert();

}

}

}

protected void Button1_Click(object sender, EventArgs e)

{

Response.Redirect("Faq.aspx");

}

protected void Button3_Click(object sender, EventArgs e)

{

MailMessage Message = new MailMessage();

Message.Subject = "subject";

Message.Body = "Уважаемый покупатель, магазин спортинвентаря сообщает Вам, что Ваш заказ на покупку 3х гандбольных мячей оформлен и Вы можете забрать товар в любое время, стоимость покупки:600000руб.";

Message.From = new System.Net.Mail.MailAddress("vdiatchik@yandex.ru");

Message.To.Add(new MailAddress("levkovich_1993@tut.by"));

System.Net.Mail.SmtpClient Smtp = new SmtpClient();

Smtp.Host = "smtp.yandex.ru";

Smtp.Port = 587;

Smtp.Credentials = new System.Net.NetworkCredential("vdiatchik@yandex.ru", "19927777");

Smtp.Send(Message);

}

protected void Button4_Click(object sender, EventArgs e)

{

Response.Redirect("Order.aspx");

}

protected void ImageButton1_Click(object sender, EventArgs e)

{

Response.Redirect("Default.aspx");

}

protected void Button5_Click(object sender, EventArgs e)

{

SqlDataSource1.DeleteCommand = "DELETE * FROM temp_table";

SqlDataSource1.Delete();

}

}

21

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]