private void tb_login_Click(object sender, EventArgs e) { using (var context = new mssqlDBContext()) { context.Database.Log += (log) => { Console.WriteLine($"log : {log}"); }; var loginInfo = new tb_logininfo() { userid = "id02", userpassword = "******" }; context.logininfo.Add(loginInfo); context.SaveChanges(); } }
private void button2_Click(object sender, EventArgs e) { using (var ctx = new ApplicationDataContext()) { var uid = textBox1.Text; var upw = textBox2.Text; // 암호화 //var key = "test1234"; var key = Properties.Resources.DecKey; var des = new DES(key); var encrypt = des.result(DesType.Encrypt, upw); //레코드 단위로 묶어주기 var item = new tb_logininfo(); //generic type, 연동 item.userid = uid; item.userpasswd = encrypt; ctx.login.Add(item); ctx.SaveChanges(); /*context.Database.Log += (log)-> * { * Console.WriteLine($"log : {log}"); * };*/ /*Console.WriteLine("데이터베이스 연결"); * var item = new tb_logininfo(); *//*{ * userid = "id123", * userpasswd = "pw123" * };*/ /*context.login.Add(loginInfo); * context.SaveChanges();*//* * item.userid = "id1234"; * item.userpasswd = "pw123"; * Console.WriteLine("레코드 정보 생성 완료"); * context.login.Add(item); * Console.WriteLine("레코드 추가"); * context.SaveChanges(); * Console.WriteLine("커밋!");*/ } }
private void addInfoBtn_Click(object sender, EventArgs e) { using (var context = new mssqlDBContext()) { string uid = newId.Text; string upw = newPwd.Text; var des = new DES(Properties.Resources.DesKey); var encrypt = des.result(DesType.Encrypt, upw); var loginInfo = new tb_logininfo() { userid = uid, userpassword = encrypt }; context.logininfo.Add(loginInfo); context.SaveChanges(); } formExit(); }