//............................Get All assign Hardware to a single User..............................
        public List <HardwareAllocated> GetUserAssignHardwareByUserId(int UserId)
        {
            List <HardwareAllocated> hardwareAllocatedItems = new List <HardwareAllocated>();

            try
            {
                using (SqlConnection con = new SqlConnection(connectionString))
                {
                    SqlCommand cmd = new SqlCommand("select b.id,c.name, a.hardwareType,b.allocationDate from tblHardwareType a inner join tblHardwareAllocated b on a.hardwareTypeId = b.hardwareTypeId inner join tblUsers c on b.userId = c.userId where b.userId=" + UserId, con);
                    con.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        HardwareAllocated hardwareAllocated = new HardwareAllocated();
                        hardwareAllocated.id             = Convert.ToInt32(rdr["id"]);
                        hardwareAllocated.name           = rdr["name"].ToString();
                        hardwareAllocated.hardwareType   = rdr["hardwareType"].ToString();
                        hardwareAllocated.allocationDate = Convert.ToDateTime(rdr["allocationDate"]);
                        hardwareAllocatedItems.Add(hardwareAllocated);
                    }
                    con.Close();
                }
            }
            catch
            {
                throw;
            }
            return(hardwareAllocatedItems);
        }
 //To Add new Item record
 public int AddIssueHardwarer(HardwareAllocated hardwareAllocated)
 {
     try
     {
         using (SqlConnection con = new SqlConnection(connectionString))
         {
             //string Query = string.Format("insert into tblHardwareAllocated (hardwareTypeId,userId,allocationDate) values ({0},{1},'{2}')", hardwareAllocated.hardwareTypeId,hardwareAllocated.userId,DateTime.Now);
             SqlCommand cmd = new SqlCommand("PS_AllottingHardware", con);
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@userId", hardwareAllocated.userId);
             cmd.Parameters.AddWithValue("@hardwareTypeId", hardwareAllocated.hardwareTypeId);
             con.Open();
             cmd.ExecuteNonQuery();
             con.Close();
         }
     }
     catch (Exception ex)
     {
         throw;
     }
     return(1);
 }