// function to fetch the details of single staff with specified staff type public List <Staff> FetchSingleStaffByType(int id, StaffTypes type) { List <Staff> StaffList = new List <Staff>(); using (SqlConnection con = new SqlConnection(ConnString)) { using (SqlCommand cmd = new SqlCommand("SPViewSingleStaff", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Id", id); cmd.Parameters.AddWithValue("@Type", type.ToString()); try { con.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { StaffList = PopulateStaff(reader); } return(StaffList); } catch (SqlException sqlExc) { return(null); } } } }
public Staffs(StaffTypes businessPartnerType) { StaffViewModel.Errors = 0; InitializeComponent(); Messenger.Default.Send <StaffTypes>(businessPartnerType); Messenger.Reset(); }
public Staff(string Name, string EmpCode, StaffTypes StaffType, string ContactNumber, DateTime DateOfJoin, int Id = 0) { this.Id = Id; this.Name = Name; this.EmpCode = EmpCode; this.StaffType = StaffType; this.ContactNumber = ContactNumber; this.DateOfJoin = DateOfJoin; }
/// <summary> /// Action to edit staff details /// </summary> /// <param name="id">Unique id of the staff.</param> /// <param name="t">Type of Staff</param> /// <returns>View showing staff details</returns> public ActionResult EditStaff(int id, StaffTypes t) { try { ViewBag.StaffId = id; HttpCookie conString = Request.Cookies.Get("rwxgqlb"); AddStaffViewModel asvm; if (t == StaffTypes.NonTeaching) { NonTeachingStaff s = new NonTeachingStaff(id, Cryptography.Decrypt(conString.Value)); asvm = new AddStaffViewModel { Address = s.Address, CNIC = s.CNIC, Gender = s.Gender, JobType = s.JobType, Salary = s.Salary, MCompanyCode = s.PhoneNumber.CompanyCode, MCountryCode = s.PhoneNumber.CountryCode, MNumber = s.PhoneNumber.Number, Name = s.Name, StaffType = t }; } else if (t == StaffTypes.Teacher) { Teacher s = new Teacher(id, Cryptography.Decrypt(conString.Value)); asvm = new AddStaffViewModel { Address = s.Address, CNIC = s.CNIC, Gender = s.Gender, Salary = s.Salary, MCompanyCode = s.PhoneNumber.CompanyCode, MCountryCode = s.PhoneNumber.CountryCode, MNumber = s.PhoneNumber.Number, Name = s.Name, StaffType = t }; } else { asvm = null; } return(View(asvm)); } catch (Exception ex) { return(Content(ex.Message)); } }
public IActionResult GetAllStaffByType([FromQuery] StaffTypes type) { var temp = Enum.IsDefined(typeof(StaffTypes), type); if (Enum.IsDefined(typeof(StaffTypes), type)) { DataBaseManager dataBaseManager = new DataBaseManager(); List <Staff> StaffList = dataBaseManager.FetchStaffByCategory(type); return(Ok(new { StaffList })); } else { return(NotFound()); } }
public IActionResult Post([FromBody] Object staff) { bool isExist = false; var jsonString = staff.ToString(); //var temp = (int)JObject.Parse(jsonString)["StaffType"]; //StaffTypes type = (StaffTypes)temp; string temp = (string)JObject.Parse(jsonString)["StaffType"]; StaffTypes type = (StaffTypes)Enum.Parse(typeof(StaffTypes), temp, true); List <Staff> StaffList = new List <Staff>(); if (type == StaffTypes.Teaching) { TeachingStaff obj = JsonConvert.DeserializeObject <TeachingStaff>(jsonString); StaffList.Add(obj); } if (type == StaffTypes.Administrative) { AdministrativeStaff obj = JsonConvert.DeserializeObject <AdministrativeStaff>(jsonString); StaffList.Add(obj); } if (type == StaffTypes.Support) { SupportStaff obj = JsonConvert.DeserializeObject <SupportStaff>(jsonString); StaffList.Add(obj); } DataBaseManager dataBaseManager = new DataBaseManager(); try { isExist = dataBaseManager.CheckCodeExistence(StaffList[0].EmpCode); if (isExist) { return(StatusCode(400)); } else { dataBaseManager.AddStaffToType(StaffList); return(StatusCode(201)); } } catch (Exception e) { return(StatusCode(500)); } }
public string[] TabControlPageNames(StaffTypes type) { switch (type) { case StaffTypes.Yönetici: return(Enum.GetNames(typeof(TabControlPages)).Select(x => " " + x.ToString() + " ").ToArray()); case StaffTypes.SatınAlma: return(Enum.GetNames(typeof(TabControlPages)).Select(x => " " + x.ToString() + " ").Take(5).ToArray()); case StaffTypes.BölümŞefi: return(new string[1] { "Rapor" }); default: return(null); } }
public MetroFramework.Forms.MetroForm[] AdminForms(StaffTypes type) { switch (type) { case StaffTypes.Yönetici: return(new MetroFramework.Forms.MetroForm[7] { new Views.Purchase(), new Views.Inventory(), new Views.Product(), new Views.Fixture(), new Views.Recycle(), new Views.Staff(), new Views.Report() }); case StaffTypes.SatınAlma: return(new MetroFramework.Forms.MetroForm[5] { new Views.Purchase(), new Views.Inventory(), new Views.Product(), new Views.Fixture(), new Views.Recycle() }); case StaffTypes.BölümŞefi: return(new MetroFramework.Forms.MetroForm[1] { new Views.Report() }); default: return(null); } }
public IActionResult Put(int id, [FromBody] Object staff) { var jsonString = staff.ToString(); //var temp = (int)JObject.Parse(jsonString)["StaffType"]; //StaffTypes type = (StaffTypes)temp; string temp = (string)JObject.Parse(jsonString)["StaffType"]; StaffTypes type = (StaffTypes)Enum.Parse(typeof(StaffTypes), temp, true); DataBaseManager dataBaseManager = new DataBaseManager(); try { if (type == StaffTypes.Teaching) { TeachingStaff obj = JsonConvert.DeserializeObject <TeachingStaff>(jsonString); dataBaseManager.UpdateStaff(obj); return(StatusCode(200)); } if (type == StaffTypes.Administrative) { AdministrativeStaff obj = JsonConvert.DeserializeObject <AdministrativeStaff>(jsonString); dataBaseManager.UpdateStaff(obj); return(StatusCode(200)); } if (type == StaffTypes.Support) { SupportStaff obj = JsonConvert.DeserializeObject <SupportStaff>(jsonString); dataBaseManager.UpdateStaff(obj); return(StatusCode(200)); } return(NotFound()); } catch (Exception e) { return(StatusCode(500)); } }
public SupportStaff(string Name, string EmpCode, StaffTypes StaffType, string Department, string ContactNumber, DateTime DateOfJoin, int Id = 0) : base(Name, EmpCode, StaffType, ContactNumber, DateOfJoin, Id) { this.Department = Department; }
public TeachingStaff(string Name, string EmpCode, StaffTypes StaffType, string Subject, string ContactNumber, DateTime DateOfJoin, int Id = 0) : base(Name, EmpCode, StaffType, ContactNumber, DateOfJoin, Id) { this.Subject = Subject; }
public AdministrativeStaff(string Name, string EmpCode, StaffTypes StaffType, string Role, string ContactNumber, DateTime DateOfJoin, int Id = 0) : base(Name, EmpCode, StaffType, ContactNumber, DateOfJoin, Id) { this.Role = Role; }