private void loginBtn_Click(object sender, EventArgs e) { this.bookStoreDataSet.Reset(); this.employeeTableAdapter.Fill(bookStoreDataSet.Employee); EmployeeRow er = this.bookStoreDataSet.Employee.Where(em => em.EmpID.Trim() == empIDTextBox.Text && em.EmpPassword.Trim() == empPasswordTextBox.Text).FirstOrDefault(); if (er == null) { MessageBox.Show("Incorrect username or password!"); } else { Employee emp = new Employee(er.EmpID, er.EmpPassword, er.EmpRole); if (emp?.EmpRole == true) { this.Hide(); new FrmMaintainBooks(emp).ShowDialog(); this.Show(); } else { this.Hide(); new FrmChangeAccount(emp).ShowDialog(); this.Show(); } } }
static void Main(string[] args) { string connectionString = @"Data Source=WKS456\SQLEXPRESS;Initial Catalog=ShopDB;Integrated Security=True"; string commandString = "SELECT * FROM Employees; SELECT * FROM Orders;"; DataSet shopDB = new DataSet("ShopDB"); SqlDataAdapter adapter = new SqlDataAdapter(commandString, connectionString); adapter.Fill(shopDB); DataTable Employees = shopDB.Tables[0]; DataTable orders = shopDB.Tables[1]; shopDB.Relations.Add("Employees_Orders", Employees.Columns["EmployeeID"], orders.Columns["EmployeeID"]); // Employees.Columns.Add("CountSale", typeof(double), "SUM(Child(Employees_Orders).EmployeeID)"); foreach (DataRow EmployeeRow in Employees.Rows) { // метод GetChaildRows получает дочерние строки в виде массива DataRow[] DataRow[] chilRows = EmployeeRow.GetChildRows("Employees_Orders"); if (chilRows.Length != 0) // если существуют дочерние записи { //Console.WriteLine("{0} {1} {2}", EmployeeRow[2], EmployeeRow[1], EmployeeRow[3]); //foreach (DataRow ordersRow in chilRows) // Console.WriteLine("\tOrderId: {0}, OrderDate: {1};", ordersRow["OrderID"], ordersRow["OrderDate"]); // Console.WriteLine(); } } }
public TableAdjustment EditTrainsStaffMember(LatticeData <Employee, EmployeeRow> latticeData, EmployeeRow employeeRow) { if (string.IsNullOrEmpty(employeeRow.UserId)) { return(latticeData.Adjust(x => x .Message(LatticeMessage.User("failure", "Editing", "Can not create create new employee from here")) )); } Employee employee = _context.Employees .FirstOrDefault(x => x.UserId == employeeRow.UserId); if (employee == null) { return(latticeData.Adjust(x => x .Message(LatticeMessage.User("failure", "Editing", "Can not find employee")) )); } employee.TrainId = employeeRow.TrainId; _context.SaveChanges(); return(latticeData.Adjust(x => x .Update(employeeRow) .Message(LatticeMessage.User("success", "Editing", "Employee saved")) )); }
public void ShouldReturnQueryForAddingEmployee() { string expected = "INSERT INTO public.ett_employee (first_name, last_name, employee_number) VALUES('Daniel', 'Moon', 'b003223');"; EmployeeRow obj = new EmployeeRow { EmployeeNumber = "b003223", LastName = "Moon", FirstName = "Daniel" }; string actual = QueryGenerator.AddEmployee(obj); Assert.Equal(expected, actual); }
public EmployeeRow AddEmployeeRow(string Address, string FirstName, string JobType, string LastName, System.Decimal Salary) { EmployeeRow rowEmployeeRow = ((EmployeeRow)(this.NewRow())); rowEmployeeRow.ItemArray = new object[] { Address, null, FirstName, JobType, LastName, Salary }; this.Rows.Add(rowEmployeeRow); return(rowEmployeeRow); }
public EmployeeRow AddEmployeeRow(System.Guid IID, string Name, string Code, string Phone, string Address) { EmployeeRow rowEmployeeRow = ((EmployeeRow)(this.NewRow())); object[] columnValuesArray = new object[] { IID, Name, Code, Phone, Address }; rowEmployeeRow.ItemArray = columnValuesArray; this.Rows.Add(rowEmployeeRow); return(rowEmployeeRow); }
public EmployeeRow AddEmployeeRow(string FirstName, string LastName, string Address, string JobType, decimal Salary) { EmployeeRow rowEmployeeRow = ((EmployeeRow)(this.NewRow())); object[] columnValuesArray = new object[] { null, FirstName, LastName, Address, JobType, Salary }; rowEmployeeRow.ItemArray = columnValuesArray; this.Rows.Add(rowEmployeeRow); return(rowEmployeeRow); }
private void Form1_Load(object sender, EventArgs e) { string connectionString = @"Data Source=МИХАИЛ-ПК\MSSQLSERVER1;Initial Catalog=ShopDB;Integrated Security=True"; string commandString = "SELECT EmployeeID FROM Employees; SELECT * FROM Orders;"; DataSet shopDB = new DataSet("ShopDB"); SqlDataAdapter adapter = new SqlDataAdapter(commandString, connectionString); adapter.Fill(shopDB); DataTable Employees = shopDB.Tables[0]; DataTable orders = shopDB.Tables[1]; shopDB.Relations.Add("Employees_Orders", Employees.Columns["EmployeeID"], orders.Columns["EmployeeID"]); Employees.Columns.Add("CountSale", typeof(double), "Count(Child(Employees_Orders).EmployeeID)"); foreach (DataRow EmployeeRow in Employees.Rows) { // метод GetChaildRows получает дочерние строки в виде массива DataRow[] DataRow[] chilRows = EmployeeRow.GetChildRows("Employees_Orders"); // if (chilRows.Length != 0) // если существуют дочерние записи // { dataGridView1.DataSource = Employees; foreach (DataRow ordersRow in chilRows) { Console.WriteLine("\tOrderId: {0}, OrderDate: {1};", ordersRow["OrderID"], ordersRow["OrderDate"]); } Console.WriteLine(); //} } }
public EmployeeRowChangeEvent(EmployeeRow row, global::System.Data.DataRowAction action) { this.eventRow = row; this.eventAction = action; }
public void RemoveEmployeeRow(EmployeeRow row) { this.Rows.Remove(row); }
public void AddEmployeeRow(EmployeeRow row) { this.Rows.Add(row); }
public EmployeeRowChangeEvent(EmployeeRow row, DataRowAction action) { this.eventRow = row; this.eventAction = action; }
public static string AddEmployee(EmployeeRow employeeObject) { return($"INSERT INTO public.ett_employee (first_name, last_name, employee_number) VALUES('{employeeObject.FirstName}', '{employeeObject.LastName}', '{employeeObject.EmployeeNumber}');"); }