private void btnEdiLoginInfo_Click(object sender, EventArgs e) { // MessageBox.Show("Not implemented"); LoginInfo current = cbLoginInfo.SelectedItem as LoginInfo; formCreateNewLoginInfo loginForm = new formCreateNewLoginInfo(current.Url, current.Username, current.Password); if (loginForm.ShowDialog() == DialogResult.OK) { LoginInfo modifiedInfo = loginForm.GetLoginInfo(); using (DBEntities context = new DBEntities()) { try { var login = (from o in context.LoginInfoes where o.Id == current.Id select o).First(); login.Username = modifiedInfo.Username; login.Url = modifiedInfo.Url; login.Password = modifiedInfo.Password; context.SaveChanges(); this.refreshLoginInfo(); } catch (Exception ex) { MessageBox.Show("btnEdiLoginInfo_Click" + "\n\n" + ex.ToString()); } } } }
private void btnAddLoginInfo_Click(object sender, EventArgs e) { Project p = lbProjects.SelectedItem as Project; int projectId = p.Id; formCreateNewLoginInfo createNewLoginInfo = new formCreateNewLoginInfo(); if (createNewLoginInfo.ShowDialog() == DialogResult.OK) { LoginInfo l = createNewLoginInfo.GetLoginInfo(); l.ProjectId = projectId; try { using (DBEntities entitties = new DBEntities()) { entitties.LoginInfoes.Add(l); entitties.SaveChanges(); } this.refreshLoginInfo(); } catch (Exception ex) { MessageBox.Show("btnAddloginInfo_click\n\n" + ex.ToString()); } } }