PDA

View Full Version : مشکل ذخیره نشدن تغییرات در دیتابیس



NOSRATGOLAB
سه شنبه 04 مهر 1391, 22:37 عصر
سلام من یک دکمه دارم وقتی فیلدی را تغییر میدم و رو دکمه کلیک میکنم هیچ اتفاقی نمیفته یعنی مثلا فیلد رشته رو از آیتی میکنم کامپیوتر بعد رو دکمه ثبت تغییرات کلیک میکنم باز همون آیتیه
تو رو خدا کمک کنید پدرم دراومد

protected void savebtn_Click(object sender, EventArgs e)
{
var db = new DataClasses1DataContext();

txtoname.BackColor = System.Drawing.Color.White;
txtofamily.BackColor = System.Drawing.Color.White;
txtssid.BackColor = System.Drawing.Color.White;
txtreshte.BackColor = System.Drawing.Color.White;
txtsal.BackColor = System.Drawing.Color.White;
txtsemail.BackColor = System.Drawing.Color.White;
msgl.Text = "";

if (txtoname.Text == "")
{
txtoname.BackColor = System.Drawing.Color.Red;
return;
}
if (txtofamily.Text == "")
{
txtofamily.BackColor = System.Drawing.Color.Red;
return;
}
if (txtssid.Text == "")
{
txtssid.BackColor = System.Drawing.Color.Red;
return;
}
if (txtreshte.Text == "")
{
txtreshte.BackColor = System.Drawing.Color.Red;
return;
}
if (txtsal.Text == "")
{
txtsal.BackColor = System.Drawing.Color.Red;
return;
}
if (txtsemail.Text == "")
{
txtsemail.BackColor = System.Drawing.Color.Red;
return;
}
string user = txtuser.Text;
string pass = FormsAuthentication.HashPasswordForStoringInConfig File(txtpass.Text, "md5");
string nname = txtoname.Text;
string ffamily = txtofamily.Text;
string nsid = txtssid.Text;
string nreshte = txtreshte.Text;
string nsal = txtsal.Text;
string nemail = txtsemail.Text;
//=================
var q = db.ot_students.Where(c => c.username == txtuser.Text).Single();
//txtuser.Text = q.username;
txtoname.Text = q.sname;

txtofamily.Text = q.sfamily;
txtssid.Text = q.ssid;
txtreshte.Text = q.reshte;
txtsal.Text = q.sal;
txtsemail.Text = q.semail;

db.SubmitChanges();

txtuser.ReadOnly = true;
Panel1.Visible = false;
txtuser.Text = "";
txtpass.Text = "";
txtoname.Text = "";
txtofamily.Text = "";
txtssid.Text = "";
txtreshte.Text = "";
txtsal.Text = "";
txtsemail.Text = "";
student_grid.DataBind();
}