// left at stored procedures static void Main(string[] args) { DataLayer.DB.ApplicationName = "ciccio pasticcio"; DataLayer.DB.ConnectionTimeout = 60; //var conn = DataLayer.DB.GetSqlConnection(); // Console.WriteLine(DataLayer.DB.ConnectionString); var employees = new Employees(); var id = 1; var emp = employees.GetEmployee(id); //Console.Write(emp.FirstName); DataLayer.SSApplicationLog.Add("serached for id " + id); //DataLayer.ApplicationLog.DeleteCommentsForApp("ciccio pasticcio"); var personRepo = new PersonRepository(); var andrea = new Person() { FirstName = "Chelsea", LastName = "Cremese" }; personRepo.Insert(andrea); //personRepo.Delete(andrea); //var p = personRepo.Find(1); //Console.Write(p.LastName); var a = personRepo.Read(); // fot this you'd need to create your own expression tree. //var p = personRepo.Find(p => p.FirstName == "Andrea"); Console.Read(); }
private void buttonGetEmployee_Click(object sender, EventArgs e) { try { var es = new DataLayer.Employees(); DataLayer.DB.EnableStatistics = true; var employee = es.GetEmployee(int.Parse(textBoxEID.Text)); RefreshStatistics(DataLayer.DB.LastStatistics); DataLayer.DB.EnableStatistics = false; textBoxFName.Text = employee.FirstName; textBoxLName.Text = employee.LastName; textBoxDName.Text = employee.DepartmentName; labelDepartmentId.Text = employee.DepartmentId.ToString(); labelOldName.Text = employee.DepartmentName; labelOldName.Visible = true; DataLayer.ApplicatioLog.Add4($"Searched for user id: {textBoxEID.Text}"); DataTable tableLog = DataLayer.ApplicatioLog.GetLog(this.AppName); dataGridViewAppLog.DataSource = tableLog; } catch (SqlException sqlex) { // Connection error... MessageBox.Show(this, sqlex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception) { } }
protected void LinkButtonGetEmployee_Click(object sender, EventArgs e) { try { Employees es = new DataLayer.Employees(); Employee employee = es.GetEmployeeBySp(int.Parse(TextBoxEID.Text)); TextBoxFName.Text = employee.FirstName; TextBoxLName.Text = employee.LastName; TextBoxDName.Text = employee.DepartmentName; } catch (Exception err) { Console.WriteLine("{0} Exception: ", err); } }
private void linkLabelUpdateDepartmentName_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { try { // A search must first be performed if (textBoxEID.Text.Length > 0 && textBoxDName.Text.Length > 0) { DataLayer.Employees employees = new DataLayer.Employees(); int departmentId = int.Parse(labelDepartmentId.Text); employees.UpdateDepartmentName(departmentId, textBoxDName.Text, labelOldName.Text); buttonGetEmployee_Click(sender, null); } } catch (SqlException sqlex) { // Connection error... MessageBox.Show(this, sqlex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch { } }