private void addEmployeeButton_Click(object sender, EventArgs e) { if (employeesDataGridView.CurrentCell is null) { return; } using (var cn = Database.CreateConnection()) { cn.Open(); OracleCommand cmd = new OracleCommand("INSERT INTO departaments_employees (departament_id, employee_id) " + "VALUES (:dep, :empl)", cn); cmd.Parameters.Add(new OracleParameter("dep", departament_id)); cmd.Parameters.Add(new OracleParameter("empl", employees[employeesDataGridView.CurrentCell.RowIndex].id)); try { cmd.ExecuteNonQuery(); employees = EmployeesDataSet.GetAvailableEmployees(departament_id); employeesDataGridView.DataSource = employees; DepartsEmplsDataSet.Update(); records = DepartsEmplsDataSet.GetRecordsForDepartament(departament_id); recordsDataGridView.DataSource = records; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public static EmployeesDataSet GetContactDetails() { EmployeesDataSet dsEmployees = null; // Attempt to retrieve from cache ICacheManager cache = EnterpriseLibraryContainer.Current.GetInstance <ICacheManager>(); dsEmployees = (EmployeesDataSet)cache[CACHE_KEY]; // Retrieve from dataProvider if not in Cache and Online if (dsEmployees == null && ConnectionManager.IsOnline) { EmployeeDataProvider dataProvider = new EmployeeDataProvider(); dsEmployees = dataProvider.GetEmployees(); // Expire in 2 days AbsoluteTime expiry = new AbsoluteTime(new TimeSpan(2, 0, 0, 0)); cache.Add( CACHE_KEY, dsEmployees, CacheItemPriority.High, null, new ICacheItemExpiration[] { expiry }); } return(dsEmployees); }
public bool CreateNewEmployee(string strFirstName, string strGroup, string strHomeOffice, string strLastName, string strPhoneNumber, string strType) { bool blnFatalError = false; try { TheEmployeesDataSet = GetEmployeesInfo(); EmployeesDataSet.employeesRow NewEmployeeRow = TheEmployeesDataSet.employees.NewemployeesRow(); NewEmployeeRow.Active = true; NewEmployeeRow.EmployeeID = CreateEmployeeID(); NewEmployeeRow.FirstName = strFirstName; NewEmployeeRow.EmployeeGroup = strGroup; NewEmployeeRow.HomeOffice = strHomeOffice; NewEmployeeRow.LastName = strLastName; NewEmployeeRow.PhoneNumber = strPhoneNumber; NewEmployeeRow.EmployeeType = strType; TheEmployeesDataSet.employees.Rows.Add(NewEmployeeRow); UpdateEmployeesDB(TheEmployeesDataSet); } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Employee DLL // Create New Employee // " + Ex.Message); blnFatalError = true; } return(blnFatalError); }
private void deleteEmployeeButton_Click(object sender, EventArgs e) { if (recordsDataGridView.CurrentCell is null) { return; } using (var cn = Database.CreateConnection()) { cn.Open(); OracleCommand cmd = new OracleCommand("DELETE FROM departaments_employees WHERE id=:id", cn); cmd.Parameters.Add(new OracleParameter("id", records[recordsDataGridView.CurrentCell.RowIndex].id)); try { cmd.ExecuteNonQuery(); employees = EmployeesDataSet.GetAvailableEmployees(departament_id); employeesDataGridView.DataSource = employees; DepartsEmplsDataSet.Update(); records = DepartsEmplsDataSet.GetRecordsForDepartament(departament_id); recordsDataGridView.DataSource = records; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public MainForm() { InitializeComponent(); ProjectsDataSet.Update(); projects = ProjectsDataSet.GetData(); DepartamentsDataSet.Update(); departaments = DepartamentsDataSet.GetData(); EmployeesDataSet.Update(); employees = EmployeesDataSet.GetData(); projectsDataGridView.DataSource = projects; projectsDataGridView.Columns[0].Visible = false; projectsDataGridView.Columns[3].HeaderText = "departament"; projectsDataGridView.Columns[4].HeaderText = "begin date"; projectsDataGridView.Columns[5].HeaderText = "end date"; projectsDataGridView.Columns[6].HeaderText = "real end date"; projectDepartamnetComboBox.DataSource = departaments; departamentsDataGridView.DataSource = departaments; departamentsDataGridView.Columns[0].Visible = false; employeesDataGridView.DataSource = employees; employeesDataGridView.Columns[0].Visible = false; employeesDataGridView.Columns[1].HeaderText = "first name"; employeesDataGridView.Columns[2].HeaderText = "last name"; employeesDataGridView.Columns[3].HeaderText = "father name"; }
public override global::System.Data.DataSet Clone() { EmployeesDataSet cln = ((EmployeesDataSet)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
/// <summary> /// Get contact details for all employees from the database /// </summary> /// <returns>An EmployeesDataSet filled with the contact details</returns> public EmployeesDataSet GetEmployees() { EmployeesDataSet dsEmployees = new EmployeesDataSet(); employeesTableAdapter1.Fill(dsEmployees.Employees); return dsEmployees; }
private void employeeUpdateButton_Click(object sender, EventArgs e) { if (employeeFirstNameTextBox.TextLength == 0) { MessageBox.Show("Enter first name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); employeeFirstNameTextBox.Focus(); return; } if (employeeLastNameTextBox.TextLength == 0) { MessageBox.Show("Enter last name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); employeeLastNameTextBox.Focus(); return; } if (employeeFatherNameTextBox.TextLength == 0) { MessageBox.Show("Enter father name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); employeeFatherNameTextBox.Focus(); return; } if (employeePositionTextBox.TextLength == 0) { MessageBox.Show("Enter position", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); employeePositionTextBox.Focus(); return; } using (var cn = Database.CreateConnection()) { cn.Open(); OracleCommand cmd = new OracleCommand("UPDATE employees SET first_name=:n, last_name=:ln, father_name=:fn, position=:p," + "salary=:s WHERE id=:id", cn); cmd.Parameters.Add(new OracleParameter("n", employeeFirstNameTextBox.Text)); cmd.Parameters.Add(new OracleParameter("ln", employeeLastNameTextBox.Text)); cmd.Parameters.Add(new OracleParameter("fn", employeeFatherNameTextBox.Text)); cmd.Parameters.Add(new OracleParameter("p", employeePositionTextBox.Text)); cmd.Parameters.Add(new OracleParameter("s", employeeSalaryNumericUpDown.Value)); cmd.Parameters.Add(new OracleParameter("id", employees[employeesDataGridView.CurrentCell.RowIndex].id)); try { cmd.ExecuteNonQuery(); EmployeesDataSet.Update(); employees = EmployeesDataSet.GetData(); employeesDataGridView.DataSource = employees; employeeFirstNameTextBox.Text = ""; employeeFatherNameTextBox.Text = ""; employeeLastNameTextBox.Text = ""; employeePositionTextBox.Text = ""; employeeSalaryNumericUpDown.Value = 0; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public static EmployeesDataSet GetContactDetails() { EmployeesDataSet dsEmployees = null; EmployeeDataProvider dataProvider = new EmployeeDataProvider(); dsEmployees = dataProvider.GetEmployees(); return(dsEmployees); }
private void MainForm_Load(object sender, EventArgs e) { this.ToolStripLabel1.Text = ConnectionManager.StatusText; // Load data into the 'EmployeesDataSet'. EmployeesDataSet tempDataset = EmployeeService.GetContactDetails(); if (tempDataset != null) { this.EmployeesDataSet.Merge(tempDataset); } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { EmployeesDataSet ds = new EmployeesDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
public static EmployeesDataSet GetContactDetails() { EmployeesDataSet dsEmployees = null; // TODO: Add persistent caching with time-out EmployeeDataProvider dataProvider = new EmployeeDataProvider(); dsEmployees = dataProvider.GetEmployees(); return(dsEmployees); }
public void UpdateEmployeesDB(EmployeesDataSet aEmployeesDataSet) { try { aEmployeesTableAdapter = new EmployeesDataSetTableAdapters.employeesTableAdapter(); aEmployeesTableAdapter.Update(aEmployeesDataSet.employees); } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Employee DLL // Update Employees DB // " + Ex.Message); } }
private void employeeAddButton_Click(object sender, EventArgs e) { if (employeeFirstNameTextBox.TextLength == 0) { MessageBox.Show("Enter first name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); employeeFirstNameTextBox.Focus(); return; } if (employeeLastNameTextBox.TextLength == 0) { MessageBox.Show("Enter last name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); employeeLastNameTextBox.Focus(); return; } if (employeeFatherNameTextBox.TextLength == 0) { MessageBox.Show("Enter father name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); employeeFatherNameTextBox.Focus(); return; } if (employeePositionTextBox.TextLength == 0) { MessageBox.Show("Enter position", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); employeePositionTextBox.Focus(); return; } using (var cn = Database.CreateConnection()) { cn.Open(); OracleCommand cmd = new OracleCommand("INSERT INTO employees (first_name, last_name, father_name, position, salary) " + "VALUES (:n, :ln, :fn, :p, :s)", cn); cmd.Parameters.Add(new OracleParameter("n", employeeFirstNameTextBox.Text)); cmd.Parameters.Add(new OracleParameter("ln", employeeLastNameTextBox.Text)); cmd.Parameters.Add(new OracleParameter("fn", employeeFatherNameTextBox.Text)); cmd.Parameters.Add(new OracleParameter("p", employeePositionTextBox.Text)); cmd.Parameters.Add(new OracleParameter("s", employeeSalaryNumericUpDown.Value)); try { cmd.ExecuteNonQuery(); EmployeesDataSet.Update(); employees = EmployeesDataSet.GetData(); employeesDataGridView.DataSource = employees; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public EmployeesDataSet GetEmployeesInfo() { try { aEmployeesDataSet = new EmployeesDataSet(); aEmployeesTableAdapter = new EmployeesDataSetTableAdapters.employeesTableAdapter(); aEmployeesTableAdapter.Fill(aEmployeesDataSet.employees); } catch (Exception Ex) { TheEventLogClass.InsertEventLogEntry(DateTime.Now, "New Employee DLL // Get Employees Info // " + Ex.Message); } return(aEmployeesDataSet); }
public ManageDepartamentEmployeesForm(Departament departament) { InitializeComponent(); departament_id = departament.id; departamentNameTextBox.Text = departament.name; employees = EmployeesDataSet.GetAvailableEmployees(departament_id); employeesDataGridView.DataSource = employees; employeesDataGridView.Columns[0].Visible = false; DepartsEmplsDataSet.Update(); records = DepartsEmplsDataSet.GetRecordsForDepartament(departament_id); recordsDataGridView.DataSource = records; recordsDataGridView.Columns[0].Visible = false; }
private void employeeDeleteButton_Click(object sender, EventArgs e) { using (var cn = Database.CreateConnection()) { cn.Open(); OracleCommand cmd = new OracleCommand("DELETE FROM employees WHERE id=:id", cn); cmd.Parameters.Add(new OracleParameter("id", employees[employeesDataGridView.CurrentCell.RowIndex].id)); try { cmd.ExecuteNonQuery(); EmployeesDataSet.Update(); employees = EmployeesDataSet.GetData(); employeesDataGridView.DataSource = employees; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
// TODO: PopulateCache & BeginBackgroundLoad private static void PopulateCache() { byte[] photoData = null; EmployeesDataSet dsEmployees = GetContactDetails(); if (dsEmployees == null) { return; } ICacheManager cache = EnterpriseLibraryContainer.Current.GetInstance <ICacheManager>(); foreach (EmployeesDataSet.EmployeesRow employee in dsEmployees.Employees) { if (!cache.Contains(employee.EmployeeID.ToString())) { EmployeeDataProvider dataProvider = new EmployeeDataProvider(); photoData = dataProvider.GetEmployeePhotoData(employee.EmployeeID); cache.Add(employee.EmployeeID.ToString(), photoData); } } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); EmployeesDataSet ds = new EmployeesDataSet(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "EmployeesDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }