public IActionResult Index() { EmpClass emp = new EmpClass(); emp.flag = "get"; DataSet ds = dbop.Empget(emp, out msg); List <EmpClass> list = new List <EmpClass>(); if (ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { list.Add(new EmpClass { id = Convert.ToInt32(dr["id"]), Kadi = dr["Kadi"].ToString(), Adsoyad = dr["AdSoyad"].ToString(), Tel = dr["Tel"].ToString(), Adres = dr["Adres"].ToString(), Acik = dr["Acik"].ToString(), ekle = Convert.ToInt32(dr["ekle"]), cikar = Convert.ToInt32(dr["cikar"]), Bakiye = Convert.ToInt32(dr["Bakiye"]) }); } } return(View(list)); }
public IHttpActionResult Put(EmpClass ec) { var updateemp = cm.Sys_User.Where(x => x.Id == ec.Id).FirstOrDefault <Sys_User>(); if (updateemp != null) { updateemp.Id = ec.Id; updateemp.Empname = ec.Empname; updateemp.Empemail = ec.Empemail; updateemp.emplocation = ec.emplocation; updateemp.empdesignation = ec.empdesignation; updateemp.UserName = ec.UserName; updateemp.Password = ec.Password; updateemp.IsActive = ec.IsActive; updateemp.Role = ec.Role; updateemp.squad = ec.squad; cm.SaveChanges(); } else { return(NotFound()); } return(Ok()); }
public IActionResult Create(EmpClass ec) { _cc.Add(ec); _cc.SaveChanges(); // ViewBag.message = "REcord" + ec.Name + "Is sucess"; return(View()); }
public ActionResult Edit(EmpClass empClass) { try { DynamicParameters param = new DynamicParameters(); string createdby = HttpContext.User.Identity.Name; string updatedby = HttpContext.User.Identity.Name; param.Add("@Id", empClass.Id); param.Add("@EmpName", empClass.Empname); param.Add("@Empemail", empClass.Empemail); param.Add("@Emplocation", empClass.Emplocation); param.Add("@Empdesignation", empClass.Empdesignation); param.Add("@UserName", empClass.UserName); param.Add("@Password", empClass.Password); param.Add("@IsActive", empClass.IsActive); param.Add("@Role", empClass.Role); param.Add("@squad", empClass.Squad); param.Add("@CreatedDate", empClass.CreatedDate); param.Add("@CreatedBy", createdby); param.Add("@UpdatedDate", empClass.UpdatedDate); param.Add("@Updatedby", updatedby); DapperORM.ExecuteWithoutReturn("AddUpdateEmp", param); return(RedirectToAction("Index")); } catch (Exception) { ViewBag.message = "Invalid Credentials"; return(View()); } }
private void btnEdit_Click(object sender, EventArgs e) { if (dataEmployee.SelectedRows.Count > 0) { if (EmpClass.isDuplicatedUserName(dataEmployee, txtUserName.Text, txtEmpId.Text)) { MessageBox.Show("Username has been taken!\nPlease Kindly choose other name."); return; } if (txtPassword.Text.Length < 4) { MessageBox.Show("Password must be at least 4 characters!"); return; } txtPassword_Leave(txtPassword, null); txtPassword_Leave(txtUserName, null); txtPassword_Leave(txtSalary, null); int index = dataEmployee.SelectedRows[0].Index; dataEmployee.Rows[index].Cells[0].Value = txtEmpId.Text; dataEmployee.Rows[index].Cells[7].Value = txtAddress.Text; dataEmployee.Rows[index].Cells[2].Value = txtFirstName.Text; dataEmployee.Rows[index].Cells[3].Value = txtLastName.Text; dataEmployee.Rows[index].Cells[4].Value = (rndMale.Checked) ? "Male" : "Female"; dataEmployee.Rows[index].Cells[5].Value = dTPickerBirthDate.Value.Year + "/" + dTPickerBirthDate.Value.Month + "/" + dTPickerBirthDate.Value.Day.ToString(); dataEmployee.Rows[index].Cells[6].Value = txtPhoneNumber.Text; dataEmployee.Rows[index].Cells[8].Value = cbxPosition.SelectedItem.ToString(); dataEmployee.Rows[index].Cells[9].Value = txtSalary.Text; dataEmployee.Rows[index].Cells[10].Value = txtUserName.Text; dataEmployee.Rows[index].Cells[11].Value = txtPassword.Text; dataEmployee.Rows[index].Cells[12].Value = CheckActive.Checked; dataEmployee.Rows[index].Cells[1].Value = dTPickerIn.Value.Year + "/" + dTPickerIn.Value.Month + "/" + dTPickerIn.Value.Day.ToString(); isSaved = false; } }
public IActionResult Create(EmpClass ec) { _cc.Add(ec); _cc.SaveChanges(); ViewBag.message = "The record" + ec.EmpName + "is saved"; return(View()); }
public ActionResult Create(EmpClass empclass) { using (SqlConnection sqlconn = new SqlConnection(conn)) { sqlconn.Open(); string sqlQuery = "Insert into Employee values(@EmployeeID, @EmployeeName, @EmployeeAge, @EmployeeSalary)"; SqlCommand sqlcmd = new SqlCommand(sqlQuery, sqlconn); sqlcmd.Parameters.Add(new SqlParameter() { ParameterName = "@EmployeeID", Value = empclass.EmployeeID }); sqlcmd.Parameters.Add(new SqlParameter() { ParameterName = "@EmployeeName", Value = empclass.EmployeeName }); sqlcmd.Parameters.Add(new SqlParameter() { ParameterName = "@EmployeeAge", Value = empclass.EmployeeAge }); sqlcmd.Parameters.Add(new SqlParameter() { ParameterName = "@EmployeeSalary", Value = empclass.EmployeeSalary }); sqlcmd.ExecuteNonQuery(); // sqlcmd.Parameters.AddWithValue(@EmployeeID, empclass.EmployeeID); } return(RedirectToAction("Index")); }
public ActionResult Login(EmpClass empClass, string returnUrl) { DynamicParameters param = new DynamicParameters(); param.Add("@UserName", empClass.UserName); param.Add("@Password", empClass.Password); param.Add("@IsActive", empClass.IsActive); var dataItem = DapperORM.ReturnList <EmpClass>("Login", param).FirstOrDefault <EmpClass>(); if (dataItem != null) { FormsAuthentication.SetAuthCookie(dataItem.UserName, false); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index")); } } else { ViewBag.message = "Invalid Credentials"; return(View()); } }
public IActionResult OnPostAsync(EmpClass ecInsert) { //string connection = "Data Source=DESKTOP-GORUVUT;Initial Catalog=EMP;Integrated Security=False;User Id=user;Password=user;MultipleActiveResultSets=True"; using (SqlConnection sqlcon = new SqlConnection(connection)) { //string Insertdata = "Insert into [EMP].[dbo].[NewEmployee] Values('" + ecInsert.Empname + "','" + ecInsert.Email + "','" + ecInsert.Age + "','" + ecInsert.Salary + "')"; //using(SqlCommand sqlcom = new SqlCommand(Insertdata, sqlcon)) //{ // sqlcon.Open(); // sqlcom.ExecuteNonQuery(); //} using (SqlCommand sqlcom = new SqlCommand("[dbo].[AddEmployee]", sqlcon)) { sqlcom.CommandType = CommandType.StoredProcedure; sqlcom.Parameters.Add("@Empname", SqlDbType.VarChar).Value = ecInsert.Empname; sqlcom.Parameters.Add("@Email", SqlDbType.VarChar).Value = ecInsert.Email; sqlcom.Parameters.Add("@Age", SqlDbType.Int).Value = ecInsert.Age; sqlcom.Parameters.Add("@Salary", SqlDbType.Decimal).Value = ecInsert.Salary; sqlcon.Open(); sqlcom.ExecuteNonQuery(); } } return(RedirectToPage("Index")); }
public static List <EmpClass> DisplayRecords() { List <EmpClass> ListObj = new List <EmpClass>(); //string connection = "Data Source=DESKTOP-GORUVUT;Initial Catalog=EMP;Integrated Security=False;User Id=user;Password=user;MultipleActiveResultSets=True"; using (SqlConnection sqlcon = new SqlConnection(connection)) { using (SqlCommand sqlcom = new SqlCommand("[dbo].[GetEmployee]", sqlcon)) { sqlcon.Open(); using (SqlDataReader sdr = sqlcom.ExecuteReader()) { while (sdr.Read()) { EmpClass ec = new EmpClass(); ec.Empid = Convert.ToInt32(sdr["Empid"]); ec.Empname = Convert.ToString(sdr["Empname"]); ec.Email = Convert.ToString(sdr["Email"]); ec.Age = Convert.ToInt32(sdr["Age"]); ec.Salary = Convert.ToDecimal(sdr["Salary"]); ListObj.Add(ec); } } } } return(ListObj); }
public List <EmpClass> CheckLogingUser(string userName, string password) { List <EmpClass> users = new List <EmpClass>(); EmpClass objemp = new EmpClass(); users = objemp.CheckLogingUser(userName, password); return(users); }
public IActionResult Create(EmpClass ec) { //_cc.Add(ec); _cc.Machines.Add(ec); _cc.SaveChanges(); ViewBag.message = "Rekord " + ec.MachineName + " został zapisany pomyślnie...!"; return(View()); }
public ActionResult Index(EmpClass obj) { if (ModelState.IsValid) { return(Redirect("/DataAnn/Index")); } return(View(obj)); }
public IActionResult Create(EmpClass ec) { conn.Add(ec); // bug here inner bug conn.SaveChanges(); ViewBag.message = ec.fname + " Has been successsfully Added"; return(View(ec)); }
private void btnAdd_Click(object sender, EventArgs e) { //Dictionary<string, string> a = new Dictionary<string, string>(); //a.Add("EmpID", "005"); //a.Add("FName", "Test"); //dataCon.exActionQuery.insertDataToDB() if (txtFirstName.Text == "" || txtLastName.Text == "" || txtUserName.Text == "" || txtPassword.Text == "" || txtSalary.Text == "" || cbxPosition.SelectedIndex < 0) { MessageBox.Show("Fill-in All Information required!"); return; } if (dataEmployee.SelectedRows.Count > 0) { DialogResult dialog = MessageBox.Show("You are selecting one or more rows!\nDo you want to clear selection?", "Warning", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { dataEmployee.ClearSelection(); return; } else { return; } } if (EmpClass.isDuplicatedUserName(dataEmployee, txtUserName.Text, txtEmpId.Text)) { MessageBox.Show("Username has been taken!\nPlease Kindly choose other name."); return; } if (txtPassword.Text.Length < 4) { MessageBox.Show("Password must be at least 4 characters!"); return; } txtPassword_Leave(txtPassword, null); txtPassword_Leave(txtUserName, null); txtPassword_Leave(txtSalary, null); string empID = txtEmpId.Text; string address = /*(txtAddress.Text == "") ? "" : */ txtAddress.Text; string firstname = txtFirstName.Text; string lastname = txtLastName.Text; string gender = (rndMale.Checked) ? "Male" : "Female"; string DOB = dTPickerBirthDate.Value.Year + "/" + dTPickerBirthDate.Value.Month + "/" + dTPickerBirthDate.Value.Day.ToString(); string Tel = (txtPhoneNumber.Text == "") ? "" : txtPhoneNumber.Text; string position = cbxPosition.SelectedItem.ToString(); string salary = txtSalary.Text; string username = txtUserName.Text; string password = txtPassword.Text; bool status = CheckActive.Checked; string dateEmployed = dTPickerIn.Value.Year + "/" + dTPickerIn.Value.Month + "/" + dTPickerIn.Value.Day.ToString(); dataTable.Rows.Add(empID, dateEmployed, firstname, lastname, gender, DOB, Tel, address, position, salary, username, password, status); txtEmpId.Text = (((Convert.ToInt32(txtEmpId.Text) + 1).ToString()).Length == 2) ? "0" + (Convert.ToInt32(txtEmpId.Text) + 1) : "00" + (Convert.ToInt32(txtEmpId.Text) + 1); defaultID = txtEmpId.Text; clearTextBox(); isSaved = false; }
public List <EmpClass> GetUsernameByID(int EmpID) { List <EmpClass> message = new List <EmpClass>(); EmpClass obj_Emp = new EmpClass(); string username = string.Empty; message = obj_Emp.GetUserNameByEmpID(EmpID); // return new EmpClass { UserName = username }; return(message); }
/// <summary> /// Constructor that assigns the employee based on a DataRow. /// </summary> /// <param name="Row">The DataRow from which the Employee is drawing data.</param> public Employee(DataRow Row) { SSN = Row["SSN"].ToString(); FName = Row["FName"].ToString(); LName = Row["LName"].ToString(); ID = Row["EmployeeID"].ToString(); MI = Row["MI"].ToString(); DB = Row["DB"].ToString(); EmployeeClass = getEmpClass(Row["EmplClass"].ToString().ToUpper().Trim(), Row["DB"].ToString().ToUpper()); TMWDriverID = (string)Row["TMWDriverID"]; }
public ActionResult Delete(EmpClass empClass) { string updatedby = HttpContext.User.Identity.Name; DynamicParameters param = new DynamicParameters(); param.Add("@Id", empClass.Id); param.Add("@Updatedby", updatedby); param.Add("@UpdatedDate", empClass.UpdatedDate); DapperORM.ExecuteWithoutReturn("DeleteEmpById", param); return(RedirectToAction("Index")); }
public void OnGet(int empid) { EmpClass ec = new EmpClass(); // string connection = "Data Source=DESKTOP-GORUVUT;Initial Catalog=EMP;Integrated Security=False;User Id=user;Password=user;MultipleActiveResultSets=True"; //string sqlquery = "SELECT [Empid],[Empname],[Email],[Age],[Salary] FROM [EMP].[dbo].[NewEmployee] WHERE [Empid] = '" + empid + "' "; //using (SqlConnection sqlcon = new SqlConnection(connection)) //{ // using (SqlCommand sqlcmd = new SqlCommand(sqlquery, sqlcon)) // { // sqlcon.Open(); // using (SqlDataReader sdr = sqlcmd.ExecuteReader()) // { // while (sdr.Read()) // { // ec.Empid = Convert.ToInt32(sdr["Empid"]); // ec.Empname = Convert.ToString(sdr["Empname"]); // ec.Email = Convert.ToString(sdr["Email"]); // ec.Age = Convert.ToInt32(sdr["Age"]); // ec.Salary = Convert.ToInt32(sdr["Salary"]); // } // } // } //} using (SqlConnection sqlcon = new SqlConnection(connection)) { using (SqlCommand sqlcom = new SqlCommand("[dbo].[GetEmployeeById]", sqlcon)) { sqlcom.CommandType = CommandType.StoredProcedure; sqlcom.Parameters.Add("@Empid", SqlDbType.VarChar).Value = empid; sqlcon.Open(); using (SqlDataReader sdr = sqlcom.ExecuteReader()) { while (sdr.Read()) { ec.Empid = Convert.ToInt32(sdr["Empid"]); ec.Empname = Convert.ToString(sdr["Empname"]); ec.Email = Convert.ToString(sdr["Email"]); ec.Age = Convert.ToInt32(sdr["Age"]); ec.Salary = Convert.ToDecimal(sdr["Salary"]); } } } } DisplayRecords = ec; }
public ActionResult Delete(int id, EmpClass collection) { try { // TODO: Add delete logic here dc.EmployeeStoreProcedure(id, null, null, null, null, "Delete"); dc.SubmitChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(int id, EmpClass collection) { try { // TODO: Add update logic here dc.EmployeeStoreProcedure(id, collection.EmployeeName, collection.DepartmentID, collection.EmailID, collection.DOJ, "Update"); dc.SubmitChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(EmpClass collection) { try { // TODO: Add insert logic here dc.EmployeeStoreProcedure(null, collection.EmployeeName, collection.DepartmentID, collection.EmailID, collection.DOJ, "Insert"); dc.SubmitChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public IActionResult Bakiye(int id, [Bind] EmpClass emp) { try { emp.id = id; emp.flag = "update"; dbop.Empdml(emp, out msg); TempData["msg"] = msg; } catch (Exception ex) { TempData["msg"] = ex.Message; } return(RedirectToAction("Index")); }
public IActionResult Delete(int id) { try { EmpClass emp = new EmpClass(); emp.flag = "delete"; emp.id = id; dbop.Empdml(emp, out msg); TempData["msg"] = msg; } catch (Exception ex) { TempData["msg"] = ex.Message; } return(RedirectToAction("Index")); }
public IActionResult Index([Bind] EmpClass emp) { try { if (ModelState.IsValid) { string res = dbop.Save(emp); TempData["msg"] = res; } } catch (Exception ex) { TempData["msg"] = ex.Message; } return(View()); }
public IActionResult Create([Bind] EmpClass emp) { try { emp.flag = "insert"; dbop.Empdml(emp, out msg); TempData["msg"] = msg; } catch (Exception ex) { TempData["msg"] = ex.Message; throw; } return(RedirectToAction("Index")); }
public IHttpActionResult Put(EmpClass ec) { var Updatdata = (from x in dc.Administrators where x.Empid == ec.Empid select x).FirstOrDefault(); if (Updatdata != null) { Updatdata.Empid = ec.Empid; Updatdata.Empname = ec.Empname; Updatdata.Email = ec.Email; Updatdata.Location = ec.Location; dc.SubmitChanges(); } else { return(NotFound()); } return(Ok()); }
public ActionResult Create(EmpClass ec) { HttpClient hc = new HttpClient(); hc.BaseAddress = new Uri("https://localhost:44325/api/Empcrud"); var insertdata = hc.PostAsJsonAsync <EmpClass>("Empcrud", ec); insertdata.Wait(); var savedata = insertdata.Result; if (savedata.IsSuccessStatusCode) { return(RedirectToAction("Index")); } return(View("Create")); }
public IHttpActionResult Put(EmpClass ec) { var updateemp = (from x in dc.newemps where x.Empid == ec.Empid select x).FirstOrDefault(); if (updateemp != null) { updateemp.Empid = ec.Empid; updateemp.Empname = ec.Empname; updateemp.Email = ec.Email; updateemp.Location = ec.Location; dc.SubmitChanges(); } else { return(NotFound()); } return(Ok()); }
public ActionResult Edit(int id) { EmpClass empobj = null; HttpClient hc = new HttpClient(); hc.BaseAddress = new Uri("https://localhost:44357/api/"); var Consumeapi = hc.GetAsync("EmpCrud?id=" + id.ToString()); Consumeapi.Wait(); var readdata = Consumeapi.Result; if (readdata.IsSuccessStatusCode) { var displaydata = readdata.Content.ReadAsAsync <EmpClass>(); displaydata.Wait(); empobj = displaydata.Result; } return(View(empobj)); }