Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

ПИС Курсач (ВКЛЮЧАЕТ ВСЕ ЛР И ПР)

.pdf
Скачиваний:
13
Добавлен:
25.06.2023
Размер:
1.63 Mб
Скачать

usersfind.SelectCommand = crit; GridView1.DataBind();

//}

}

protected void GridView1_SelectedIndexChanged(Object sender, EventArgs e)

{

GridViewRow row = GridView1.SelectedRow;

LblUserID.Text = row.Cells[1].Text.ToString().Replace(" ", ""); TBsecondName.Text = row.Cells[2].Text.ToString().Replace(" ", ""); TBfirstName.Text = row.Cells[3].Text.ToString().Replace(" ", ""); TBmiddleName.Text = row.Cells[4].Text.ToString().Replace(" ", ""); TBaddress.Text = row.Cells[5].Text.ToString().Replace(" ", ""); TBpassport.Text = row.Cells[6].Text.ToString().Replace(" ", ""); TBpostIndex.Text = row.Cells[7].Text.ToString().Replace(" ", ""); TBlogin.Text = row.Cells[8].Text.ToString().Replace(" ", ""); TBpassword.Text = row.Cells[9].Text.ToString().Replace(" ", ""); CBadminStatus.Checked = ((CheckBox)row.Cells[10].Controls[0]).Checked;

if (TBsecondName.Enabled)

{

ButtonAllowChanges_Click(sender, e);

}

ButtonAllowChanges.Enabled = true; WarningUpdateUserData.Text = "";

}

protected void ButtonAllowChanges_Click(object sender, EventArgs e)

{

if (TBsecondName.Enabled)

{

ButtonAllowChanges.Text = "Разрешить изменения";

ButtonAllowChanges.BackColor = Color.LightGreen;

BupdateUserData.BackColor = Color.WhiteSmoke;

}

else

{

ButtonAllowChanges.Text = "Запретить изменения";

ButtonAllowChanges.BackColor = Color.WhiteSmoke; BupdateUserData.BackColor = Color.Turquoise;

}

TBsecondName.Enabled = !TBsecondName.Enabled;

TBfirstName.Enabled = !TBfirstName.Enabled;

TBmiddleName.Enabled = !TBmiddleName.Enabled;

TBaddress.Enabled = !TBaddress.Enabled;

TBpassport.Enabled = !TBpassport.Enabled;

TBpostIndex.Enabled = !TBpostIndex.Enabled;

TBlogin.Enabled = !TBlogin.Enabled;

TBpassword.Enabled = !TBpassword.Enabled;

CBadminStatus.Enabled = !CBadminStatus.Enabled;

BupdateUserData.Enabled = !BupdateUserData.Enabled; WarningUpdateUserData.Text = "";

}

protected void BupdateUserData_Click(object sender, EventArgs e)

{

string UpSqlQ = "UPDATE Пользователь " +

"SET Фамилия = " + TextToSqlParam(TBsecondName.Text) + ", Имя = " + TextToSqlParam(TBfirstName.Text) +

", Отчество = " + TextToSqlParam(TBmiddleName.Text) + ", Адрес = " + TextToSqlParam(TBaddress.Text) +

", Паспорт = " + TextToSqlParam(TBpassport.Text) +

", ПочтовыйИндекс = " + TextToSqlParam(TBpostIndex.Text) + ", Логин = " + TextToSqlParam(TBlogin.Text) +

", Пароль = " + TextToSqlParam(TBpassword.Text) +

", АдминСтатус = " + CBadminStatus.Checked.ToString() + " WHERE idПользователя = " + LblUserID.Text.ToString();

var connect = new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Connection PostBD"].ConnectionString);

connect.Open();

var mycom = new OleDbCommand(); mycom.CommandText = UpSqlQ; mycom.Connection = connect; mycom.ExecuteNonQuery(); connect.Close();

ButtonSelectUser_Click(sender, e);

ButtonAllowChanges_Click(sender, e);

WarningUpdateUserData.Text = "Успешно!";

}

}

}