private void button1_Click(object sender, EventArgs e) { User user = new User(); user.Name = textBox1.Text.ToString(); user.Password = textBox2.Text.ToString(); textBox1.Text = user.Name; DbContextclass db = new DbContextclass(); db.users.Add(user); db.SaveChanges(); Global.username = textBox1.Text.ToString(); viewallfile obj1 = new viewallfile(); obj1.Show(); this.Hide(); }
private void button2_Click(object sender, EventArgs e) { DbContextclass db = new DbContextclass(); try { string filename = System.IO.Path.GetFileName(openFileDialog1.FileName); if (filename == null) { MessageBox.Show("Please select a valid document."); } else { string path = Application.StartupPath.Substring(0, (Application.StartupPath.Length - 10)); Document d = new Document(); { d.Name = filename; d.Url = "file"; d.UserId = int.Parse(textBox2.Text); d.IsSharable = checkBox1.Checked; d.IsStarred = checkBox2.Checked; }; db.document.Add(d); db.SaveChanges(); MessageBox.Show("Document uploaded."); viewallfile v = new viewallfile(); v.Show(); this.Hide(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }