private void button3_Click(object sender, EventArgs e) { var nw = new DataClasses2DataContext(); liked removeFromGroup = (from gm in nw.likeds where (gm.userid == userid) && (gm.musicid == musicid) select gm).SingleOrDefault(); try { nw.likeds.DeleteOnSubmit(removeFromGroup); nw.SubmitChanges(); nw = new DataClasses2DataContext(); var musicinfo = from a in nw.musics join b in nw.likeds on a.id equals b.musicid where b.userid == uid select new { id = a.id, name = a.name, jhanr = a.jhanrid, path = a.fileaddress }; dataGridView2.DataSource = musicinfo; } catch { Console.WriteLine("has been deleted befor!!"); } }
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { MessageBox.Show("changed"); DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex]; Console.WriteLine(row); Console.WriteLine(dataGridView1.Rows[e.RowIndex].Cells["id"].Value); Console.WriteLine(dataGridView1.Rows[e.RowIndex].Cells["name"].Value); Console.WriteLine(dataGridView1.Rows[e.RowIndex].Cells["username"].Value); Console.WriteLine(dataGridView1.Rows[e.RowIndex].Cells["pas"].Value); Console.WriteLine(dataGridView1.Rows[e.RowIndex].Cells["saletavalod"].Value); Console.WriteLine(dataGridView1.Rows[e.RowIndex].Cells["ismodir"].Value); try { var db = new DataClasses2DataContext(); user myuser = db.users.Single(p => p.id == Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells["id"].Value.ToString())); myuser.pas = dataGridView1.Rows[e.RowIndex].Cells["pas"].Value.ToString(); myuser.name = dataGridView1.Rows[e.RowIndex].Cells["name"].Value.ToString(); myuser.username = dataGridView1.Rows[e.RowIndex].Cells["username"].Value.ToString(); myuser.saletavalod = Int32.Parse(dataGridView1.Rows[e.RowIndex].Cells["saletavalod"].Value.ToString()); myuser.ismodir = dataGridView1.Rows[e.RowIndex].Cells["ismodir"].Value.ToString(); db.SubmitChanges(); string message = "changed!"; MessageBox.Show(message); // this.Close(); } catch { MessageBox.Show(" not changed"); } }
private void button1_Click(object sender, EventArgs e) { try { var db = new DataClasses2DataContext(); user myuser = db.users.Single(p => p.id == uid); myuser.pas = textBox1.Text; db.SubmitChanges(); string message = "password changed!"; MessageBox.Show(message); this.Close(); } catch { MessageBox.Show("password not changed"); } }
private void button1_Click(object sender, EventArgs e) { var dbn = new DataClasses2DataContext(); var query = from c in dbn.musics select c; DataClasses2DataContext db = new DataClasses2DataContext(); music myp = new music(); myp.fileaddress = textBox1.Text; myp.name = textBox2.Text; myp.jhanrid = Int32.Parse(textBox3.Text); db.musics.InsertOnSubmit(myp); db.SubmitChanges(); MessageBox.Show("added!"); //this.Close(); }
private void button1_Click(object sender, EventArgs e) { if (userid == -1) { MessageBox.Show("no user selected"); return; } else { MessageBox.Show(userid.ToString()); } var nw = new DataClasses2DataContext(); user removeFromGroup = (from gm in nw.users where (gm.id == userid) select gm).SingleOrDefault(); try { nw.users.DeleteOnSubmit(removeFromGroup); nw.SubmitChanges(); nw = new DataClasses2DataContext(); var uinfo = from a in nw.users select new { id = a.id, name = a.name, jhanr = a.username, path = a.pas, tavalod = a.saletavalod, email = a.email, ismodir = a.ismodir }; dataGridView1.DataSource = uinfo; userid = -1; } catch { Console.WriteLine("has been deleted befor!!"); MessageBox.Show("has been deleted befor!!"); MessageBox.Show(userid.ToString()); } }
private void button1_Click(object sender, EventArgs e) { var dbn = new DataClasses2DataContext(); var query = from c in dbn.pishnahads select c; DataClasses2DataContext db = new DataClasses2DataContext(); pishnahad myp = new pishnahad(); myp.name_new_music_pishnahadi = textBox1.Text; myp.userid = uid; db.pishnahads.InsertOnSubmit(myp); db.SubmitChanges(); MessageBox.Show("sent!"); this.Close(); }
private void button2_Click(object sender, EventArgs e) { try { DataClasses2DataContext db = new DataClasses2DataContext(); liked a = new liked(); a.musicid = musicid; a.userid = userid; db.likeds.InsertOnSubmit(a); db.SubmitChanges(); } catch { Console.WriteLine("has been aded befor!!"); } }
private void button1_Click(object sender, EventArgs e) { var dbn = new DataClasses2DataContext(); var query = from c in dbn.users select c; DataClasses2DataContext db = new DataClasses2DataContext(); user emp = new user(); emp.username = textBox1.Text; emp.pas = textBox2.Text; emp.name = textBox3.Text; emp.email = textBox5.Text; emp.ismodir = "no"; emp.saletavalod = Int32.Parse(textBox4.Text); db.users.InsertOnSubmit(emp); db.SubmitChanges(); this.Close(); // }