private void BtnCreate_Clicked(object sender, EventArgs e) { var realmDB = Realm.GetInstance(); var myEmployees = realmDB.All <Employess>().ToList(); var maxStudentId = 0; if (myEmployees.Count != 0) { maxStudentId = myEmployees.Max(m => m.EmployeeId) + 1; } var Employer = new Employess { EmployeeId = maxStudentId, EmployeeName = EmployeeName.Text, EmployeeSurname = EmployeeSurname.Text, EmployeeAge = EmployeeAge.Text, EmployeeCountry = EmployeeCountry.Text }; realmDB.Write(() => { realmDB.Add(Employer); }); var employeeList = realmDB.All <Employess>().ToList(); lstCreate.ItemsSource = employeeList; }
private void btnDelete_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you sure you wanna delete this? ", "Delete Employee", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { int index = this.gridServiceStaff.Rows.IndexOf((GridViewDataRowInfo)this.gridServiceStaff.CurrentRow); if (index < 0) { return; } Employess employess = (Employess)gridServiceStaff.Rows[index].DataBoundItem; if (employess != null) { employessBll.Remove(employess.ID); } } else if (dialogResult == DialogResult.No) { this.Hide(); StaffForm form = new StaffForm(); form.ShowDialog(); } }
private void btnOK_Click(object sender, EventArgs e) { Employess employess = new Employess(); employess.ID = int.Parse(txtEmployeeID.Text); employess.Name = txtNameStaff.Text; employess.LastName = txtLastNameStaff.Text; employess.Username = txtUsernameStaff.Text; employess.Password = txtPasswordStaff.Text; employess.PersonalID = txtPersonalID.Text; employess.Adress = txtAddress.Text; employess.Birthday = DateTime.Parse(rdDatetimepicker.Text); employess.Email = txtEmail.Text; employess.PhoneNumber = txtPhoneNumber.Text; employess.Salary = double.Parse(txtSalary.Text); employess.UpdatedBy = txtUpdateBy.Text; employess.UpdateDate = DateTime.Parse(txtUpdateDate.Text); employess.LastUpdate = int.Parse(txtUpdateNo.Text); var result = employessBll.Modify(employess); if (result != null) { StaffForm sf = new StaffForm(); sf.FillGrid(); this.Close(); } }
private void btnLogin_Click(object sender, EventArgs e) { string username = txtUsername.Text; string password = txtPassword.Text; if (username.Trim() == "") { txtUsername.BackColor = Color.Red; txtUsername.Focus(); return; } if (password.Trim() == "") { txtPassword.BackColor = Color.Red; txtPassword.Focus(); return; } LoginBLL login = new LoginBLL(); Employess employess = login.Login(username, password); if (employess == null) { MessageBox.Show("Kontrolloni Username / Password"); } else { UserSession.LoggedUser = employess; this.Close(); } }
public int GetEmployeeID(Employess employee) { // create a sql connection SqlConnection connection = OpeConnection(); // write a sql query string sqlQuery = @"INSERT INTO Employees(Name, LastName, PositionId) VALUES(@Name, @LastName, @PositionId)"; string sqlQuery1 = @"SELECT EmployeeId FROM Employees where Name = @Name AND LastName = @LastName"; // execute the sql query SqlCommand insertCommand = new SqlCommand(sqlQuery, connection); insertCommand.Parameters.AddWithValue("@Name", employee.name); insertCommand.Parameters.AddWithValue("@LastName", employee.lastName); insertCommand.Parameters.AddWithValue("@PositionId", employee.position); insertCommand.ExecuteNonQuery(); // execute the sql query SqlCommand selectCommand = new SqlCommand(sqlQuery1, connection); selectCommand.Parameters.AddWithValue("@Name", employee.name); selectCommand.Parameters.AddWithValue("@LastName", employee.lastName); int employeeID = (int)selectCommand.ExecuteScalar(); // close the connection CloseConnection(connection); return(employeeID); }
/***registraton part- register new users***/ public void RegisterEmployee(Employess employee, Login loginInfo) { // add new user to the employee table loginInfo.employeeID = GetEmployeeID(employee); // add new employee to the login table SetLoginInfo(loginInfo); }
public async Task CreateAsync(Employess employess) { if (employess == null) { throw new Exception("Create faild!"); } _applicationDbContext.Employesses.Add(employess); await _applicationDbContext.SaveChangesAsync(); }
public Order() { order = new Orders(); emp = new Employess(); clientes = new Clientes(); cars = new Cars(); history = new History(); InitializeComponent(); }
public ActionResult Edit([Bind(Include = "id,empName")] Employess employess) { if (ModelState.IsValid) { db.Entry(employess).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employess)); }
public HttpResponseMessage PutEmployess([FromBody] Employess emp, int ID) { var client = new HttpClient(); client.BaseAddress = new Uri("https://northwind.now.sh/"); var jsonString = JsonConvert.SerializeObject(emp); var content = new StringContent(jsonString, Encoding.UTF8, "application/json"); var result = client.PutAsync("api/employess/" + ID, content).Result; return(result); }
public ActionResult Create([Bind(Include = "id,empName")] Employess employess) { if (ModelState.IsValid) { db.Employesses.Add(employess); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(employess)); }
public ActionResult DeleteConfirmed(int id) { foreach (var item in db.BuildingEmployees.Where(x => x.empID == id)) { db.BuildingEmployees.Remove(item); } Employess employess = db.Employesses.Find(id); db.Employesses.Remove(employess); db.SaveChanges(); return(RedirectToAction("Index")); }
// login private void LoginBtn_click(object sender, EventArgs e) { Employess employee = null; string userName = nameTxtBox.Text; string password = passwordTxtBox.Text; try { if (nameTxtBox.Text == "" || passwordTxtBox.Text == "") { // throw an exception if one of the text boxes is empty throw new Exception("Please enter your username/password"); } // pass the entered data to the logic/DB to check if it matches employee = login.CheckCredentials(new Login(userName, password)); if (employee == null) { // throw an exception if there is no matching with the DB throw new Exception("Please check your credentials"); } if (employee.position == Position.Waiter) // show the order form if the user is a Waiter { //add Employee info to the OrderFrom in order to know who logged in orderForm orderForm = new orderForm(employee, this); orderForm.Show(); this.Hide(); // hide the login from } else if (employee.position == Position.Manager) { ManageForm manageForm = new ManageForm(); manageForm.Show(); this.Hide(); } else { // show the kitchen/bar form if the user is a Chef/Barman KitchenBarForm kitchenBarForm = new KitchenBarForm(employee); kitchenBarForm.Show(); this.Hide(); // hide the login from } } catch (Exception exception) { // show the message MessageBox.Show(exception.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// GET: Employesses/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employess employess = db.Employesses.Find(id); if (employess == null) { return(HttpNotFound()); } return(View(employess)); }
public int CalculateSalary(Employess data) { int salary = 0; if (data.contractTypeName == "HourlySalaryEmployee") { salary = 120 * data.hourlySalary * 12; } else if (data.contractTypeName == "MonthlySalaryEmployee") { salary = data.monthlySalary * 12; } return(salary); }
public ActionResult Index(string inputID, string inputName, string inputPlaceN, string inputLine, string inputTurno) { Logger.InitLogger(); if (inputID == "" || inputName == "" || inputPlaceN == "" || inputLine == "" || inputTurno == "") { return(Content("<script language='javascript' type='text/javascript'>alert('Одно из полей пусто!');window.location.href = 'Index';</script>")); } else { try { using (SqlConnection cn = new SqlConnection()) { cn.ConnectionString = @"Data Source=patrin.ddns.net,1433;Initial Catalog=OIProject;Persist Security Info=True;User ID=sa;Password=18swlgnm"; cn.Open(); using (SqlCommand command = cn.CreateCommand()) { command.CommandText = string.Format("INSERT INTO Employee (ID, PlaceN, Line, Name, Turno) VALUES ('{0}','{1}','{2}','{3}','{4}')", inputID, inputPlaceN, inputLine, inputName, inputTurno); command.ExecuteNonQuery(); command.CommandText = string.Format("INSERT INTO Auth (ID, Password, Powers) VALUES ('{0}','{1}','{2}')", inputID, "0000", "Работник"); command.ExecuteNonQuery(); } cn.Close(); Employess load = new Employess(); Tablets load_tab = new Tablets(); Defects load_def = new Defects(); ArrayList allData = new ArrayList(); load.LoadData(); load_tab.PingAndLoadTablets(); load_def.LoadDefects(); allData.Add(load); allData.Add(load_def); allData.Add(load_tab); Logger.Log.Info("Добавление работника в БД"); return(View(allData)); } } catch (Exception ex) { Logger.Log.Error(ex.Message); return(Content("<script language='javascript' type='text/javascript'>alert('Ошибка в ходе добавления!" + ex.Message + "');window.location.href = 'Index';</script>")); } } }
public orderForm(Employess employee, Form form) { InitializeComponent(); // show the name of the user who logged in empNameLbl.Text = @"[" + employee.EmployeeName + @" <" + employee.position + @">" + @"]"; //save the employee ID on the form employeeID_login = employee.employeeID; // Instantiate the timer Timer t = new Timer(); t.Interval = 10000; t.Enabled = true; t.Tick += new System.EventHandler(OnTimerEvent); }
public static Boolean Login(Employess employess) { // 2 dòng này buộc phải có var conn = Conn(); conn.Open(); String sql = String.Format("select * from main.employess WHERE main.employess.phone = {0} AND main.employess.password = {1}", employess.Phone, employess.Passsword); SqlCommand command = new SqlCommand(); command.CommandText = sql; command.Connection = conn; DbDataReader reader = command.ExecuteReader(); //nếu true đăng nhập thành công return(reader.HasRows); }
public Employess GetApiData(int id) { var apiUrl = "https://northwind.now.sh/api/employess/" + id; //Connect API Uri url = new Uri(apiUrl); WebClient client = new WebClient(); client.Encoding = System.Text.Encoding.UTF8; string json = client.DownloadString(url); //END //JSON Parse START JavaScriptSerializer ser = new JavaScriptSerializer(); Employess jsonList = ser.Deserialize <Employess>(json); //END return(jsonList); }
private void button20_Click(object sender, EventArgs e) // Employees add Button { Employess emp = new Employess(); emp.lastname = textBox19.Text; emp.firstname = textBox20.Text; emp.title = textBox21.Text; emp.titleofcourtesy = textBox22.Text; emp.birthdate = maskedTextBox5.Text; emp.hiradate = maskedTextBox6.Text; emp.notes = richTextBox1.Text; var jsonString = JsonConvert.SerializeObject(emp); var client = new HttpClient(); client.BaseAddress = new Uri("https://localhost:44391/"); var content = new StringContent(jsonString, Encoding.UTF8, "application/json"); var result = client.PostAsync("api/employess", content).Result; label41.Text = "" + result; MessageBox.Show("Kayıt Eklendi."); }
public Employess CheckCredentials(Login user) { // create a sql connection SqlConnection connection = OpeConnection(); // get an employee ID int employeeID = GetEmployeeID(user); // write a sql query string SQLquery = @"SELECT EmployeeId, Name, LastName, PositionId FROM Employees WHERE EmployeeId = @EmployeeId "; // execute the sql query SqlCommand command = new SqlCommand(SQLquery, connection); command.Parameters.AddWithValue("@EmployeeId", employeeID); // read from db SqlDataReader reader = command.ExecuteReader(); Employess employee = null; if (reader.Read()) { employee = new Employess // object initializer { employeeID = (int)reader["EmployeeId"], name = Convert.ToString(reader["Name"]), lastName = Convert.ToString(reader["LastName"]), position = (Position)reader["PositionId"] }; } // close all connections reader.Close(); CloseConnection(connection); return(employee); }
public KitchenBarForm(Employess employee) { InitializeComponent(); // show the name of the employee who logged in empNameLbl.Text = @"[" + employee.EmployeeName + @" <" + (Position)employee.position + @">" + @"]"; if (employee.position == Position.Chef) { this.Text = @"Restaurant Chapeau/ Kitchen"; } else { this.Text = @"Restaurant Chapeau/ Bar"; } position = (Position)employee.position; Timer timer = new Timer(); timer.Interval = 10000; timer.Enabled = true; timer.Tick += new System.EventHandler(OnTimerEvent); }
public ActionResult Employees() { try { Logger.InitLogger(); ClaimsIdentity user = (ClaimsIdentity)(User.Identity); string type = string.Empty; string right = string.Empty; IEnumerable <Claim> claims = user.Claims; try { type = claims.ElementAt(4).Type; right = claims.ElementAt(4).Value; } catch (Exception ex) { Logger.Log.Error("Попытка несанкционированный доступ!" + ex.Message); return(Redirect("/Account/Login")); } if (type == "Rights" && right == "Работник ОК") { Employess load = new Employess(); ArrayList allData = new ArrayList(); load.LoadAllData(); allData.Add(load); return(View(allData)); } else { return(View("ErrorRight")); } } catch (Exception ex) { return(Content("<script language='javascript' type='text/javascript'>alert('Ошибка в ходе загрузки страницы!" + ex.Message + "');window.location.href = 'Index';</script>")); } }
public ActionResult Index() { try { Logger.InitLogger(); ClaimsIdentity user = (ClaimsIdentity)(User.Identity); string type = string.Empty; string right = string.Empty; IEnumerable <Claim> claims = user.Claims; try { type = claims.ElementAt(4).Type; right = claims.ElementAt(4).Value; } catch (Exception ex) { Logger.Log.Error("Попытка несанкционированного доступа!" + ex.Message); return(Redirect("/Account/Login")); } if (type == "Rights" && right == "Администратор" || right == "Работник ОК") { string browser = HttpContext.Request.Browser.Browser; string user_agent = HttpContext.Request.UserAgent; Employess load = new Employess(); Tablets load_tab = new Tablets(); Defects load_def = new Defects(); ArrayList allData = new ArrayList(); load.LoadData(); load_tab.PingAndLoadTablets(); load_def.LoadDefects(); allData.Add(load); allData.Add(load_def); allData.Add(load_tab); if (user_agent.Contains("Chrome") || (user_agent.Contains("Mozilla"))) { Logger.Log.Info("Загружена главная страница"); return(View(allData)); } else { return(Content("<script language='javascript' type='text/javascript'>alert('Сайт в данном браузере работает некорректно! Дальнейшая работа невозможна!');window.location.href = 'Index';</script>")); } } else { return(View("ErrorRight")); } } catch (Exception ex) { return(Content("<script language='javascript' type='text/javascript'>alert('Ошибка загрузки главной страницы!" + ex.Message + "');window.location.href = 'Index';</script>")); } }
public void RegisterEmployee(Employess employee, Login loginInfo) { loginDAO.RegisterEmployee(employee, loginInfo); }
private async void button2_Click(object sender, EventArgs e) { HttpClient client = new HttpClient(); LogInfo logInfo = new LogInfo(); string islem = "Kayıt Güncelleme"; TextBox tb = ((TextBox)this.Controls["UpdtextBox0"]); TextBox tb1 = ((TextBox)this.Controls["UpdtextBox1"]); TextBox tb2 = ((TextBox)this.Controls["UpdtextBox2"]); TextBox tb3 = ((TextBox)this.Controls["UpdtextBox3"]); TextBox tb4 = ((TextBox)this.Controls["UpdtextBox4"]); TextBox tb5 = ((TextBox)this.Controls["UpdtextBox5"]); TextBox tb6 = ((TextBox)this.Controls["UpdtextBox6"]); TextBox tb7 = ((TextBox)this.Controls["UpdtextBox7"]); TextBox tb8 = ((TextBox)this.Controls["UpdtextBox8"]); TextBox tb9 = ((TextBox)this.Controls["UpdtextBox9"]); TextBox tb10 = ((TextBox)this.Controls["UpdtextBox10"]); TextBox tb11 = ((TextBox)this.Controls["UpdtextBox11"]); TextBox tb12 = ((TextBox)this.Controls["UpdtextBox12"]); TextBox tb13 = ((TextBox)this.Controls["UpdtextBox13"]); TextBox tb14 = ((TextBox)this.Controls["UpdtextBox14"]); switch (Form1.which) { case "categories": Categories cat = new Categories(); cat.name = tb1.Text; cat.description = tb2.Text; var convertedInf = JsonConvert.SerializeObject(cat); var stringContent = new StringContent(convertedInf, Encoding.UTF8, "application/json"); WebAPI.ApıDal <Categories> .PatchAsync(client, stringContent, Form1.which, id); logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which); MessageBox.Show("Kayıt Başarıyla Güncellendi!"); break; case "orders": Orders or = new Orders(); WebAPI.ApıDal <Orders> .PostMethod(or, "orders"); or.customerId = tb1.Text; or.orderDate = tb2.Text; or.requiredDate = tb3.Text; or.shippedDate = tb4.Text; or.freight = Convert.ToDouble(tb5.Text); or.shipName = tb6.Text; convertedInf = JsonConvert.SerializeObject(or); stringContent = new StringContent(convertedInf, Encoding.UTF8, "application/json"); WebAPI.ApıDal <Orders> .PatchAsync(client, stringContent, Form1.which, id); logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which); MessageBox.Show("Kayıt Başarıyla Güncellendi!"); break; case "employess": Employess emp = new Employess(); emp.firstName = tb1.Text; emp.lastName = tb2.Text; emp.title = tb3.Text; emp.titleOfCourtesy = tb4.Text; emp.birthDate = tb5.Text; emp.hireDate = tb6.Text; emp.notes = tb8.Text; emp.reportsTo = tb9.Text; convertedInf = JsonConvert.SerializeObject(emp); stringContent = new StringContent(convertedInf, Encoding.UTF8, "application/json"); WebAPI.ApıDal <Employess> .PatchAsync(client, stringContent, Form1.which, id); logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which); MessageBox.Show("Kayıt Başarıyla Güncellendi!"); break; case "products": Products prod = new Products(); prod.name = tb1.Text; prod.quantityPerUnit = tb2.Text; prod.unitPrice = Convert.ToInt32(tb3.Text); prod.unitsInStock = Convert.ToInt32(tb4.Text); prod.unitsOnOrder = Convert.ToInt32(tb5.Text); prod.reorderLevel = Convert.ToInt32(tb6.Text); convertedInf = JsonConvert.SerializeObject(prod); stringContent = new StringContent(convertedInf, Encoding.UTF8, "application/json"); WebAPI.ApıDal <Products> .PatchAsync(client, stringContent, Form1.which, id); logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which); MessageBox.Show("Kayıt Başarıyla Güncellendi!"); break; case "customers": Customers cust = new Customers(); cust.companyName = tb1.Text; cust.contactName = tb2.Text; cust.contactTitle = tb3.Text; convertedInf = JsonConvert.SerializeObject(cust); stringContent = new StringContent(convertedInf, Encoding.UTF8, "application/json"); WebAPI.ApıDal <Customers> .PatchAsync(client, stringContent, Form1.which, custid); logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which); MessageBox.Show("Kayıt Başarıyla Güncellendi!"); break; case "suppliers": Suppliers supp = new Suppliers(); supp.companyName = tb1.Text; supp.contactName = tb2.Text; supp.contactTitle = tb3.Text; convertedInf = JsonConvert.SerializeObject(supp); stringContent = new StringContent(convertedInf, Encoding.UTF8, "application/json"); WebAPI.ApıDal <Suppliers> .PatchAsync(client, stringContent, Form1.which, id); logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which); MessageBox.Show("Kayıt Başarıyla Güncellendi!"); break; case "shippers": Shippers shipp = new Shippers(); shipp.companyName = tb1.Text; shipp.phone = tb2.Text; convertedInf = JsonConvert.SerializeObject(shipp); stringContent = new StringContent(convertedInf, Encoding.UTF8, "application/json"); WebAPI.ApıDal <Shippers> .PatchAsync(client, stringContent, Form1.which, id); logInfo.AddLog(islem, convertedInf + " Güncellendi", "basarili", Form1.which); MessageBox.Show("Kayıt Başarıyla Güncellendi"); break; default: break; } }
public Employess Add(Employess entity) { return(_EmployeesDal.Add(entity)); }
public void Delete(Employess entity) { _EmployeesDal.Delete(entity); }
public Employess Update(Employess entity) { return(_EmployeesDal.Update(entity)); }
public Employess CheckCredentials(Login user) { Employess employeee = loginDAO.CheckCredentials(user); return(employeee); }