private void btnModify_Click(object sender, EventArgs e) { //Get agent from selection int agentId = Convert.ToInt32(dgvAgents.SelectedRows[0].Cells[0].Value); try { agent = AgentDB.GetAgent(agentId); frmAgentModify modifyAgentForm = new frmAgentModify(); modifyAgentForm.addAgent = false; modifyAgentForm.agent = agent; DialogResult result = modifyAgentForm.ShowDialog(); if (result == DialogResult.OK) { agent = modifyAgentForm.agent; SearchFor(); } else if (result == DialogResult.Retry) { //this.GetAgent(agent.AgentId); SearchFor(); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }
private void btnLogin_Click(object sender, EventArgs e) { try { string enteredAgentId = txtAgentId.Text; string enteredPassword = txtPassword.Text; //AgentDB agentToCheck = new AgentDB(); agentExists = AgentDB.CheckPassword(enteredAgentId, enteredPassword); if (agentExists) { this.Hide(); frmMain mainForm = new frmMain(); //presenting the main form mainForm.agent = AgentDB.GetAgent(Convert.ToInt32(enteredAgentId)); mainForm.ShowDialog(); this.Close(); } else { MessageBox.Show("You entered an invalid AgentID or Password"); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }