public ActionResult EmployeeUserType(EmployeeUserType employee) { if (ModelState.IsValid) { try { if (superadminManager.IsUserRoleSet(employee)) { ViewBag.ShowMsg = "User Role Was Already Set!"; } else { int message = superadminManager.EmployeeUserType(employee); if (message > 0) { ViewBag.ShowMsg = "Employee User Typed Saved Successfully!"; } else { ViewBag.ShowMsg = "Sorry! Data Not Saved! Please Try Again"; } } } catch (Exception exception) { ViewBag.ShowMsg = exception.Message; } } ViewBag.ListOfEmployees = superadminManager.ListOfEmployee(); ViewBag.userType = superadminManager.GetUserType(); return(View()); }
protected void Page_Load(object sender, EventArgs e) { string userTypeID = Request.QueryString["userTypeID"] as string; string nationalCode = Request.QueryString["nationalCode"] as string; if (userTypeID == null || nationalCode == null) { Response.Redirect("Z_EmployeeUserTypeDefault.aspx"); } try { employeeUserTypeUserTypeID = Convert.ToInt32(userTypeID.Trim()); employeeUserTypeNationalCode = Convert.ToInt64(nationalCode.Trim()); employeeUserTypeHandler = new EmployeeUserTypeHandler(); EmployeeUserType employeeUserType = employeeUserTypeHandler.GetDetails(employeeUserTypeUserTypeID, employeeUserTypeNationalCode); lblUserTypeID.Text = employeeUserType.UserTypeID.ToString(); lblNationalCode.Text = employeeUserType.NationalCode.ToString(); lblEmployeeFullName.Text = employeeUserType.EmployeeFullName.ToString(); lblUserTypeIDTitle.Text = employeeUserType.UserTypeIDTitle.ToString(); } catch (Exception) { Response.Redirect("Z_EmployeeUserTypeDefault.aspx"); } }
public List <EmployeeUserType> SearchLike(EmployeeUserType employeeUserType) { List <EmployeeUserType> listEmployeeUserType = new List <EmployeeUserType>(); SqlParameter[] parametersEmployeeUserType = new SqlParameter[] { new SqlParameter("@UserTypeID", employeeUserType.UserTypeID), new SqlParameter("@NationalCode", employeeUserType.NationalCode), new SqlParameter("@EmployeeFullName", employeeUserType.EmployeeFullName), new SqlParameter("@UserTypeIDTitle", employeeUserType.UserTypeIDTitle), }; using (DataTable table = SqlDBHelper.ExecuteParamerizedSelectCommand("EmployeeUserType_SearchLike", CommandType.StoredProcedure, parametersEmployeeUserType)) { if (table.Rows.Count > 0) { foreach (DataRow row in table.Rows) { EmployeeUserType tmpEmployeeUserType = new EmployeeUserType(); tmpEmployeeUserType.UserTypeID = (row["UserTypeID"] != DBNull.Value) ? Convert.ToInt32(row["UserTypeID"]) : 0; tmpEmployeeUserType.NationalCode = (row["NationalCode"] != DBNull.Value) ? Convert.ToInt64(row["NationalCode"]) : 0; tmpEmployeeUserType.EmployeeFullName = row["EmployeeFullName"].ToString(); tmpEmployeeUserType.UserTypeIDTitle = row["UserTypeIDTitle"].ToString(); listEmployeeUserType.Add(tmpEmployeeUserType); } } } return(listEmployeeUserType); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label lblUserTypeID = GridView1.Rows[e.RowIndex].FindControl("lblUserTypeID") as Label; Label lblNationalCode = GridView1.Rows[e.RowIndex].FindControl("lblNationalCode") as Label; Label lblEmployeeFullName = GridView1.Rows[e.RowIndex].FindControl("lblEmployeeFullName") as Label; Label lblUserTypeIDTitle = GridView1.Rows[e.RowIndex].FindControl("lblUserTypeIDTitle") as Label; if (lblUserTypeID != null && lblNationalCode != null && lblEmployeeFullName != null && lblUserTypeIDTitle != null) { EmployeeUserType employeeUserType = new EmployeeUserType(); employeeUserType.UserTypeID = Convert.ToInt32(lblUserTypeID.Text.Trim()); employeeUserType.NationalCode = Convert.ToInt64(lblNationalCode.Text.Trim()); employeeUserType.EmployeeFullName = lblEmployeeFullName.Text; employeeUserType.UserTypeIDTitle = lblUserTypeIDTitle.Text; //Let us now update the database if (employeeUserTypeHandler.Update(employeeUserType) == true) { lblResult.Text = "Record Updated Successfully"; } else { lblResult.Text = "Failed to Update record"; } //end the editing and bind with updated records. GridView1.EditIndex = -1; BindData(); } }
public bool IsUserRoleSet(EmployeeUserType leaveTaken) { try { string Query = "SELECT * FROM tb_EmployeeUserType WHERE (EmployeeId = @EmployeeId and UserTypeId = @UserTypeId)"; SqlCommand Command = new SqlCommand(Query, con); con.Open(); Command.Parameters.Clear(); Command.Parameters.Add("EmployeeId", SqlDbType.Int); Command.Parameters["EmployeeId"].Value = leaveTaken.EmployeeId; Command.Parameters.Add("UserTypeId", SqlDbType.Int); Command.Parameters["UserTypeId"].Value = leaveTaken.UserTypeId; SqlDataReader Reader = Command.ExecuteReader(); Reader.Read(); bool isExist = Reader.HasRows; Reader.Close(); return(isExist); } catch (Exception exception) { throw new Exception("Unable to connect Server", exception); } finally { con.Close(); } }
public List <EmployeeUserType> GetListEmployeeUserType(int userTypeID) { List <EmployeeUserType> listEmployeeUserType = new List <EmployeeUserType>() { }; SqlParameter[] parametersUserType = new SqlParameter[] { new SqlParameter("@UserTypeID", userTypeID) }; //Lets get the list of EmployeeUserType records from database using (DataTable table = SqlDBHelper.ExecuteParamerizedSelectCommand("EmployeeUserType_GetList_UseInUserType", CommandType.StoredProcedure, parametersUserType)) { //check if any record exists or not if (table.Rows.Count > 0) { //Lets go ahead and create the list of employeeUserType listEmployeeUserType = new List <EmployeeUserType>(); //Now lets populate the EmployeeUserType details into the list of employeeUserTypes foreach (DataRow row in table.Rows) { EmployeeUserType employeeUserType = ConvertRowToEmployeeUserType(row); listEmployeeUserType.Add(employeeUserType); } } } return(listEmployeeUserType); }
public ActionResult SetEmployeeUserType(EmployeeUserType employee) { if (ModelState.IsValid) { try { if (_passwordAndDesignation.IsUserRoleSet(employee)) { ViewBag.ShowMsg = "User Role Set alrady."; } else { int message = _passwordAndDesignation.SetEmployeeUserType(employee); if (message > 0) { ViewBag.ShowMsg = "User Type Save Successfully!"; } else { ViewBag.ShowMsg = "Opps! Data Not Saved! Try Again Please"; } } } catch (Exception exception) { ViewBag.ShowMsg = exception.Message; } } ViewBag.userType = _passwordAndDesignation.GetUserType(); ViewBag.ListOfEmployees = _passwordAndDesignation.ListOfEmployee(); return(View()); }
public bool Exists(EmployeeUserType employeeUserType) { SqlParameter[] parametersEmployeeUserType = new SqlParameter[] { new SqlParameter("@UserTypeID", employeeUserType.UserTypeID), new SqlParameter("@NationalCode", employeeUserType.NationalCode) }; return(SqlDBHelper.ExecuteScalar("EmployeeUserType_Exists", CommandType.StoredProcedure, parametersEmployeeUserType) > 0); }
public bool Update(EmployeeUserType employeeUserType) { SqlParameter[] parametersEmployeeUserType = new SqlParameter[] { new SqlParameter("@UserTypeID", employeeUserType.UserTypeID), new SqlParameter("@NationalCode", employeeUserType.NationalCode) }; return(SqlDBHelper.ExecuteNonQuery("EmployeeUserType_Update", CommandType.StoredProcedure, parametersEmployeeUserType)); }
public Int64 Insert(EmployeeUserType employeeUserType) { SqlParameter[] parametersEmployeeUserType = new SqlParameter[] { new SqlParameter("@UserTypeID", (employeeUserType.UserTypeID > 0) ? employeeUserType.UserTypeID : (object)DBNull.Value), new SqlParameter("@NationalCode", (employeeUserType.NationalCode > 0) ? employeeUserType.NationalCode : (object)DBNull.Value) }; return(SqlDBHelper.ExecuteScalar("EmployeeUserType_Insert", CommandType.StoredProcedure, parametersEmployeeUserType)); }
private EmployeeUserType ConvertRowToEmployeeUserType(DataRow row) { EmployeeUserType employeeUserType = new EmployeeUserType(); employeeUserType.UserTypeID = (row["UserTypeID"] != DBNull.Value) ? Convert.ToInt32(row["UserTypeID"]) : 0; employeeUserType.NationalCode = (row["NationalCode"] != DBNull.Value) ? Convert.ToInt64(row["NationalCode"]) : 0; employeeUserType.EmployeeFullName = row["EmployeeFullName"].ToString(); employeeUserType.UserTypeIDTitle = row["UserTypeIDTitle"].ToString(); return(employeeUserType); }
public HttpResponseMessage PostEmployeeUserType(EmployeeUserType employee) { var messages = _passwordAndDesignation.SetEmployeeUserType(employee); if (messages != null) { var message = Request.CreateResponse(HttpStatusCode.Created, messages); return(message); } return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Category not created")); }
public string SetEmployeeUserType(EmployeeUserType employee) { if (_passwordAndDesignation.IsUserRoleSet(employee)) { return("User Role Set alrady."); } if (_passwordAndDesignation.SetEmployeeUserType(employee) > 0) { return("User Type Save Successfully!"); } return("User Type Save Faild"); }
protected void btnYES_Click(object sender, EventArgs e) { EmployeeUserType employeeUserType = new EmployeeUserType(); employeeUserType.UserTypeID = Convert.ToInt32(ddlUserTypeID.SelectedValue); employeeUserType.NationalCode = Convert.ToInt64(ddlNationalCode.SelectedValue); EmployeeUserTypeHandler employeeUserTypeHandler = new EmployeeUserTypeHandler(); if (employeeUserTypeHandler.Insert(employeeUserType) > 0) { Response.Redirect("Z_EmployeeUserTypeDefault.aspx"); } }
public int SetEmployeeUserType(EmployeeUserType employee) { string query = "INSERT INTO EmployeeUserType (EmployeeId,UserTypeId) VALUES ('" + employee.EmployeeId + "','" + employee.UserTypeId + "')"; try { _conn.Open(); SqlCommand command = new SqlCommand(query, _conn); int rowAffected = command.ExecuteNonQuery(); return(rowAffected); } catch (Exception exception) { throw new Exception("Unable to connect Server", exception); } finally { _conn.Close(); } }
public bool IsUserRoleSet(EmployeeUserType leaveRequest) { try { const string query = "select * from EmployeeUserType where (EmployeeId = @EmployeeId and UserTypeId = @UserTypeId)"; var command = new SqlCommand(query, Connection); Connection.Open(); command.Parameters.Clear(); command.Parameters.Add("EmployeeId", SqlDbType.Int); command.Parameters["EmployeeId"].Value = leaveRequest.EmployeeId; command.Parameters.Add("UserTypeId", SqlDbType.Int); command.Parameters["UserTypeId"].Value = leaveRequest.UserTypeId; SqlDataReader reader = command.ExecuteReader(); reader.Read(); bool isExist = reader.HasRows; reader.Close(); return(isExist); } catch (Exception exception) { throw new Exception("Unable to Connect Server", exception); } }
public List <EmployeeUserType> GetListAll() { List <EmployeeUserType> listEmployeeUserType = null; using (DataTable table = SqlDBHelper.ExecuteSelectCommand("EmployeeUserType_GetListAll", CommandType.StoredProcedure)) { if (table.Rows.Count > 0) { listEmployeeUserType = new List <EmployeeUserType>(); foreach (DataRow row in table.Rows) { EmployeeUserType employeeUserType = new EmployeeUserType(); employeeUserType.UserTypeID = (row["UserTypeID"] != DBNull.Value) ? Convert.ToInt32(row["UserTypeID"]) : 0; employeeUserType.NationalCode = (row["NationalCode"] != DBNull.Value) ? Convert.ToInt64(row["NationalCode"]) : 0; employeeUserType.EmployeeFullName = row["EmployeeFullName"].ToString(); employeeUserType.UserTypeIDTitle = row["UserTypeIDTitle"].ToString(); listEmployeeUserType.Add(employeeUserType); } } } return(listEmployeeUserType); }
public EmployeeUserType GetDetails(int userTypeID, Int64 nationalCode) { EmployeeUserType employeeUserType = new EmployeeUserType(); SqlParameter[] parametersEmployeeUserType = new SqlParameter[] { new SqlParameter("@UserTypeID", userTypeID), new SqlParameter("@NationalCode", nationalCode) }; using (DataTable table = SqlDBHelper.ExecuteParamerizedSelectCommand("EmployeeUserType_GetDetails", CommandType.StoredProcedure, parametersEmployeeUserType)) { if (table.Rows.Count == 1) { DataRow row = table.Rows[0]; employeeUserType.UserTypeID = (row["UserTypeID"] != DBNull.Value) ? Convert.ToInt32(row["UserTypeID"]) : 0; employeeUserType.NationalCode = (row["NationalCode"] != DBNull.Value) ? Convert.ToInt64(row["NationalCode"]) : 0; employeeUserType.EmployeeFullName = row["EmployeeFullName"].ToString(); employeeUserType.UserTypeIDTitle = row["UserTypeIDTitle"].ToString(); } } return(employeeUserType); }
public int SetEmployeeUserType(EmployeeUserType employee) { return(_passwordAndDesignation.SetEmployeeUserType(employee)); }
public bool IsUserRoleSet(EmployeeUserType employee) { return(_passwordAndDesignation.IsUserRoleSet(employee)); }
public bool IsUserRoleSet(EmployeeUserType employee) { return(adminGateway.IsUserRoleSet(employee)); }
public ActionResult SetEmployeeUserType(EmployeeUserType employee) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:32331"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = client.PostAsJsonAsync("api/UserType/PostEmployeeUserType", employee).Result; if (response.IsSuccessStatusCode) { string msg = response.Content.ReadAsStringAsync().Result; var records = JsonConvert.DeserializeObject(msg); // JSON.Net ViewBag.ShowMsg = records; } } using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:32331"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync("api/Password/").Result; string res = ""; using (HttpContent content = response.Content) { // ... Read the string. Task <string> result = content.ReadAsStringAsync(); res = result.Result; var records = JsonConvert.DeserializeObject <List <UserType> >(res); // JSON.Net foreach (UserType record in records) { var category = (string.Format("Id: {0}, UserTypeName: {1}", record.Id, record.UserTypeName)); } ViewBag.userType = records; } } using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:32331"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync("api/Whouse/").Result; string res = ""; using (HttpContent content = response.Content) { // ... Read the string. Task <string> result = content.ReadAsStringAsync(); res = result.Result; var records = JsonConvert.DeserializeObject <List <Employee> >(res); // JSON.Net foreach (Employee record in records) { var category = (string.Format("Id: {0}, EmployeeName: {1}", record.Id, record.EmployeeName)); } ViewBag.ListOfEmployees = records; } } return(View()); }
public bool IsUserRoleSet(EmployeeUserType leaveRequest) { return(_superadminGateway.IsUserRoleSet(leaveRequest)); }
public int EmployeeUserType(EmployeeUserType employee) { return(_superadminGateway.SetEmployeeUserType(employee)); }