public SaleForm(EmployeeModel employee) { this.employee = employee; InitializeComponent(); this.label_idOperator.Text = "0000" + employee.EmployeeID.ToString(); getAllProducts(); saleItems = new List<ItemModel>(); }
private EmployeeModel doLogin(string username, string password) { EmployeeModel employee = null; using (SqlConnection sqlConn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\MarotoDB.mdf;Integrated Security=True;")) { using (SqlCommand sqlCommand = new SqlCommand()) { sqlCommand.Parameters.AddWithValue("username", username); sqlCommand.Parameters.AddWithValue("password", password); sqlCommand.CommandText = "SELECT * FROM EMPLOYEE WHERE NAME = @username AND PASSWORD = @password"; sqlCommand.Connection = sqlConn; sqlConn.Open(); SqlDataReader dataReader; dataReader = sqlCommand.ExecuteReader(); if (dataReader.Read()) { employee = new EmployeeModel(Int32.Parse(dataReader["ID"].ToString()), dataReader[1].ToString(), dataReader[2].ToString(), Int32.Parse(dataReader["LEVEL"].ToString()), dataReader[4].ToString(), dataReader[5].ToString()); } sqlConn.Close(); } } return employee; }